mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 15:09:04 +00:00
Refactor browser test enqueuing in test scripts.
R=ricow@google.com Review URL: https://codereview.chromium.org//700753004 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@41633 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
parent
9bf0729a4a
commit
ea27275aa6
|
@ -2,9 +2,6 @@
|
|||
# for details. All rights reserved. Use of this source code is governed by a
|
||||
# BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
no_linked_scripts_htmltest: Skip # HTML tests are under development
|
||||
scripts_htmltest: Skip # HTML tests are under development
|
||||
|
||||
event_test: Skip # Issue 1996
|
||||
interactive_test: Skip # Must be run manually.
|
||||
dromaeo_smoke_test: Skip # Issue 14521, 8257
|
||||
|
@ -124,6 +121,8 @@ serialized_script_value_test: Fail
|
|||
websocket_test/websocket: Fail # TODO(efortuna): Issue 7875.
|
||||
canvasrenderingcontext2d_test/drawImage_video_element: Fail # IE does not support drawImage w/ video element
|
||||
canvasrenderingcontext2d_test/drawImage_video_element_dataUrl: Fail # IE does not support drawImage w/ video element
|
||||
no_linked_scripts_htmltest: Skip # Times out on IE. Issue 21537
|
||||
scripts_htmltest: Skip # Times out on IE. Issue 21537
|
||||
|
||||
[$runtime == ie10 ]
|
||||
# IE10 Feature support statuses-
|
||||
|
|
|
@ -27,7 +27,7 @@ END_HTML_DART_TEST
|
|||
parent.postMessage('ko', '*');
|
||||
window.postMessage('hest', '*');
|
||||
}
|
||||
setTimeout(delayed, 5000);
|
||||
setTimeout(delayed, 500);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -841,9 +841,7 @@ class StandardTestSuite extends TestSuite {
|
|||
info.optionsFromFile['isMultitest'] ? info.multitestKey : "");
|
||||
Set<Expectation> expectations = testExpectations.expectations(testName);
|
||||
if (info is HtmlTestInformation) {
|
||||
if (TestUtils.isBrowserRuntime(configuration['runtime'])) {
|
||||
enqueueBrowserTest([], null, info, testName, expectations);
|
||||
}
|
||||
enqueueHtmlTest(info, testName, expectations);
|
||||
return;
|
||||
}
|
||||
var filePath = info.filePath;
|
||||
|
@ -1151,92 +1149,51 @@ class StandardTestSuite extends TestSuite {
|
|||
* subTestName, Set<String>> if we are running a browser multi-test (one
|
||||
* compilation and many browser runs).
|
||||
*/
|
||||
void enqueueBrowserTest(List<Command> baseCommands,
|
||||
void enqueueBrowserTest(
|
||||
List<Command> baseCommands,
|
||||
Path packageRoot,
|
||||
TestInformation info,
|
||||
String testName,
|
||||
expectations) {
|
||||
RegExp badChars = new RegExp('[-=/]');
|
||||
List VmOptionsList = getVmOptions(info.optionsFromFile);
|
||||
bool multipleOptions = VmOptionsList.length > 1;
|
||||
for (var vmOptions in VmOptionsList) {
|
||||
String optionsName =
|
||||
multipleOptions ? vmOptions.join('-').replaceAll(badChars, '') : '';
|
||||
String tempDir = createOutputDirectory(info.filePath, optionsName);
|
||||
enqueueBrowserTestWithOptions(
|
||||
baseCommands,
|
||||
packageRoot,
|
||||
info,
|
||||
testName,
|
||||
expectations,
|
||||
vmOptions,
|
||||
tempDir);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void enqueueBrowserTestWithOptions(
|
||||
List<Command> baseCommands,
|
||||
Path packageRoot,
|
||||
TestInformation info,
|
||||
String testName,
|
||||
expectations,
|
||||
List<String> vmOptions,
|
||||
String tempDir) {
|
||||
// TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot]
|
||||
// on to the browser (it may be test specific).
|
||||
|
||||
// TODO(kustermann/ricow): This method should be refactored.
|
||||
Map optionsFromFile = info.optionsFromFile;
|
||||
Path filePath = info.filePath;
|
||||
String filename = filePath.toString();
|
||||
|
||||
final String compiler = configuration['compiler'];
|
||||
final String runtime = configuration['runtime'];
|
||||
final Map optionsFromFile = info.optionsFromFile;
|
||||
|
||||
if (info is HtmlTestInformation) {
|
||||
final String tempDir = createOutputDirectory(info.filePath, '');
|
||||
final Uri tempUri = new Uri.file('$tempDir/');
|
||||
final Uri htmlFile = tempUri.resolve(filePath.filename);
|
||||
new File.fromUri(htmlFile).writeAsStringSync(htmlTest.getContents(info));
|
||||
|
||||
void createFailingTest(String message) {
|
||||
var msg = "$message: ${info.filePath}";
|
||||
DebugLogger.warning(msg);
|
||||
new File.fromUri(htmlFile).writeAsStringSync(
|
||||
htmlTest.makeFailingHtmlFile(msg));
|
||||
}
|
||||
if (info.scripts.length > 0) {
|
||||
Uri testUri = new Uri.file(filePath.toNativePath());
|
||||
for (String scriptPath in info.scripts) {
|
||||
if (!scriptPath.endsWith('.dart') && !scriptPath.endsWith('.js')) {
|
||||
createFailingTest(
|
||||
'HTML test scripts must be dart or javascript: $scriptPath');
|
||||
break;
|
||||
}
|
||||
Uri uri = Uri.parse(scriptPath);
|
||||
if (uri.isAbsolute) {
|
||||
createFailingTest(
|
||||
'HTML test scripts must have relative paths: $scriptPath');
|
||||
break;
|
||||
}
|
||||
if (uri.pathSegments.length > 1) {
|
||||
createFailingTest(
|
||||
'HTML test scripts must be in test directory: $scriptPath');
|
||||
break;
|
||||
}
|
||||
Uri script = testUri.resolveUri(uri);
|
||||
if (compiler == 'none' || scriptPath.endsWith('.js')) {
|
||||
Uri copiedScript = tempUri.resolveUri(uri);
|
||||
new File.fromUri(copiedScript).writeAsStringSync(
|
||||
new File.fromUri(script).readAsStringSync());
|
||||
} else {
|
||||
// TODO(21514): Compile scripts into output directory.
|
||||
createFailingTest('HTML test scripts don\'t support dart2js yet');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String testDisplayName = '$suiteName/$testName';
|
||||
var htmlPath = _createUrlPathFromFile(new Path(htmlFile.toFilePath()));
|
||||
var fullHtmlPath = _getUriForBrowserTest(info, htmlPath,
|
||||
null, null);
|
||||
var commands = [CommandBuilder.instance.getBrowserHtmlTestCommand(
|
||||
runtime, fullHtmlPath, configuration, info.expectedMessages)];
|
||||
var testCase = new BrowserTestCase(testDisplayName,
|
||||
commands, configuration, expectations,
|
||||
info, isNegative(info), fullHtmlPath);
|
||||
enqueueNewTestCase(testCase);
|
||||
return;
|
||||
}
|
||||
|
||||
for (var vmOptions in getVmOptions(optionsFromFile)) {
|
||||
// Create a unique temporary directory for each set of vmOptions.
|
||||
// TODO(dart:429): Replace separate replaceAlls with a RegExp when
|
||||
// replaceAll(RegExp, String) is implemented.
|
||||
String optionsName = '';
|
||||
if (getVmOptions(optionsFromFile).length > 1) {
|
||||
optionsName = vmOptions.join('-').replaceAll('-','')
|
||||
.replaceAll('=','')
|
||||
.replaceAll('/','');
|
||||
}
|
||||
final String compilationTempDir =
|
||||
createCompilationOutputDirectory(info.filePath);
|
||||
final String tempDir = createOutputDirectory(info.filePath, optionsName);
|
||||
|
||||
String dartWrapperFilename = '$tempDir/test.dart';
|
||||
String compiledDartWrapperFilename = '$compilationTempDir/test.js';
|
||||
|
@ -1262,12 +1219,12 @@ class StandardTestSuite extends TestSuite {
|
|||
// require Pub deploy, not just polymer.
|
||||
if (customHtml.readAsStringSync().contains('<!--polymer-test')) {
|
||||
if (compiler != 'none') {
|
||||
commands.add(_polymerDeployCommand(
|
||||
customHtmlPath, tempDir, optionsFromFile));
|
||||
commands.add(
|
||||
_polymerDeployCommand(customHtmlPath, tempDir, optionsFromFile));
|
||||
|
||||
Path pubspecYamlFile = _findPubspecYamlFile(filePath);
|
||||
Path homeDir = pubspecYamlFile == null ? dir :
|
||||
pubspecYamlFile.directoryPath;
|
||||
Path homeDir =
|
||||
(pubspecYamlFile == null) ? dir : pubspecYamlFile.directoryPath;
|
||||
htmlPath = '$tempDir/${dir.relativeTo(homeDir)}/$nameNoExt.html';
|
||||
dartWrapperFilename = '${htmlPath}_bootstrap.dart';
|
||||
compiledDartWrapperFilename = '$dartWrapperFilename.js';
|
||||
|
@ -1280,16 +1237,19 @@ class StandardTestSuite extends TestSuite {
|
|||
|
||||
var htmlContents = customHtml.readAsStringSync();
|
||||
if (compiler == 'none') {
|
||||
htmlContents = htmlContents.replaceAll('%TEST_SCRIPTS%',
|
||||
'<script type="application/dart" '
|
||||
'src="${_createUrlPathFromFile(filePath)}"></script>\n'
|
||||
'<script type="text/javascript" '
|
||||
'src="/packages/browser/dart.js"></script>');
|
||||
var dartUrl = _createUrlPathFromFile(filePath);
|
||||
var dartScript =
|
||||
'<script type="application/dart" src="$dartUrl"></script>';
|
||||
var jsUrl = '/packages/browser/dart.js';
|
||||
var jsScript =
|
||||
'<script type="text/javascript" src="$jsUrl"></script>';
|
||||
htmlContents = htmlContents.replaceAll(
|
||||
'%TEST_SCRIPTS%', '$dartScript\n$jsScript');
|
||||
} else {
|
||||
compiledDartWrapperFilename = '$tempDir/$nameNoExt.js';
|
||||
var jsFile = '$nameNoExt.js';
|
||||
htmlContents = htmlContents.replaceAll('%TEST_SCRIPTS%',
|
||||
'<script src="$jsFile"></script>');
|
||||
var jsUrl = '$nameNoExt.js';
|
||||
htmlContents = htmlContents.replaceAll(
|
||||
'%TEST_SCRIPTS%', '<script src="$jsUrl"></script>');
|
||||
}
|
||||
new File(htmlPath).writeAsStringSync(htmlContents);
|
||||
}
|
||||
|
@ -1312,16 +1272,20 @@ class StandardTestSuite extends TestSuite {
|
|||
}
|
||||
scriptPath = _createUrlPathFromFile(new Path(scriptPath));
|
||||
|
||||
content =
|
||||
getHtmlContents(filename, scriptType, new Path("$scriptPath"));
|
||||
content = getHtmlContents(filename, scriptType, new Path("$scriptPath"));
|
||||
htmlTest.writeStringSync(content);
|
||||
htmlTest.closeSync();
|
||||
}
|
||||
|
||||
if (compiler != 'none') {
|
||||
commands.add(_compileCommand(
|
||||
dartWrapperFilename, compiledDartWrapperFilename,
|
||||
compiler, tempDir, vmOptions, optionsFromFile));
|
||||
commands.add(
|
||||
_compileCommand(
|
||||
dartWrapperFilename,
|
||||
compiledDartWrapperFilename,
|
||||
compiler,
|
||||
tempDir,
|
||||
vmOptions,
|
||||
optionsFromFile));
|
||||
}
|
||||
|
||||
// some tests require compiling multiple input scripts.
|
||||
|
@ -1332,9 +1296,14 @@ class StandardTestSuite extends TestSuite {
|
|||
Path fromPath = filePath.directoryPath.join(namePath);
|
||||
if (compiler != 'none') {
|
||||
assert(namePath.extension == 'dart');
|
||||
commands.add(_compileCommand(
|
||||
fromPath.toNativePath(), '$tempDir/$fileName.js',
|
||||
compiler, tempDir, vmOptions, optionsFromFile));
|
||||
commands.add(
|
||||
_compileCommand(
|
||||
fromPath.toNativePath(),
|
||||
'$tempDir/$fileName.js',
|
||||
compiler,
|
||||
tempDir,
|
||||
vmOptions,
|
||||
optionsFromFile));
|
||||
}
|
||||
if (compiler == 'none') {
|
||||
// For the tests that require multiple input scripts but are not
|
||||
|
@ -1354,8 +1323,8 @@ class StandardTestSuite extends TestSuite {
|
|||
List<Command> commandSet = new List<Command>.from(commands);
|
||||
|
||||
var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath));
|
||||
var fullHtmlPath = _getUriForBrowserTest(info, htmlPath_subtest,
|
||||
subtestNames, subtestIndex);
|
||||
var fullHtmlPath = _getUriForBrowserTest(
|
||||
info, htmlPath_subtest, subtestNames, subtestIndex);
|
||||
|
||||
List<String> args = <String>[];
|
||||
|
||||
|
@ -1375,12 +1344,19 @@ class StandardTestSuite extends TestSuite {
|
|||
dartFlags.addAll(vmOptions);
|
||||
}
|
||||
|
||||
commandSet.add(CommandBuilder.instance.getContentShellCommand(
|
||||
contentShellFilename, fullHtmlPath, contentShellOptions,
|
||||
dartFlags, environmentOverrides));
|
||||
commandSet.add(
|
||||
CommandBuilder.instance.getContentShellCommand(
|
||||
contentShellFilename,
|
||||
fullHtmlPath,
|
||||
contentShellOptions,
|
||||
dartFlags,
|
||||
environmentOverrides));
|
||||
} else {
|
||||
commandSet.add(CommandBuilder.instance.getBrowserTestCommand(
|
||||
runtime, fullHtmlPath, configuration));
|
||||
commandSet.add(
|
||||
CommandBuilder.instance.getBrowserTestCommand(
|
||||
runtime,
|
||||
fullHtmlPath,
|
||||
configuration));
|
||||
}
|
||||
|
||||
// Create BrowserTestCase and queue it.
|
||||
|
@ -1388,20 +1364,102 @@ class StandardTestSuite extends TestSuite {
|
|||
var testCase;
|
||||
if (info.optionsFromFile['isMultiHtmlTest']) {
|
||||
testDisplayName = '$testDisplayName/${subtestNames[subtestIndex]}';
|
||||
testCase = new BrowserTestCase(testDisplayName,
|
||||
commandSet, configuration,
|
||||
testCase = new BrowserTestCase(
|
||||
testDisplayName,
|
||||
commandSet,
|
||||
configuration,
|
||||
expectations['$testName/${subtestNames[subtestIndex]}'],
|
||||
info, isNegative(info), fullHtmlPath);
|
||||
info,
|
||||
isNegative(info),
|
||||
fullHtmlPath);
|
||||
} else {
|
||||
testCase = new BrowserTestCase(testDisplayName,
|
||||
commandSet, configuration, expectations,
|
||||
info, isNegative(info), fullHtmlPath);
|
||||
testCase = new BrowserTestCase(
|
||||
testDisplayName,
|
||||
commandSet,
|
||||
configuration,
|
||||
expectations,
|
||||
info,
|
||||
isNegative(info),
|
||||
fullHtmlPath);
|
||||
}
|
||||
|
||||
enqueueNewTestCase(testCase);
|
||||
subtestIndex++;
|
||||
} while (subtestIndex < subtestNames.length);
|
||||
}
|
||||
|
||||
void enqueueHtmlTest(
|
||||
HtmlTestInformation info,
|
||||
String testName,
|
||||
expectations) {
|
||||
final String compiler = configuration['compiler'];
|
||||
final String runtime = configuration['runtime'];
|
||||
// Html tests work only with the browser controller.
|
||||
if (!TestUtils.isBrowserRuntime(runtime) || runtime == 'drt') {
|
||||
return;
|
||||
}
|
||||
|
||||
final Path filePath = info.filePath;
|
||||
final String tempDir = createOutputDirectory(filePath, '');
|
||||
final Uri tempUri = new Uri.file('$tempDir/');
|
||||
String contents = htmlTest.getContents(info);
|
||||
|
||||
void Fail(String message) {
|
||||
var msg = "$message: ${info.filePath}";
|
||||
DebugLogger.warning(msg);
|
||||
contents = htmlTest.makeFailingHtmlFile(msg);
|
||||
}
|
||||
|
||||
if (info.scripts.length > 0) {
|
||||
Uri testUri = new Uri.file(filePath.toNativePath());
|
||||
for (String scriptPath in info.scripts) {
|
||||
if (!scriptPath.endsWith('.dart') && !scriptPath.endsWith('.js')) {
|
||||
Fail('HTML test scripts must be dart or javascript: $scriptPath');
|
||||
break;
|
||||
}
|
||||
Uri uri = Uri.parse(scriptPath);
|
||||
if (uri.isAbsolute) {
|
||||
Fail('HTML test scripts must have relative paths: $scriptPath');
|
||||
break;
|
||||
}
|
||||
if (uri.pathSegments.length > 1) {
|
||||
Fail('HTML test scripts must be in test directory: $scriptPath');
|
||||
break;
|
||||
}
|
||||
Uri script = testUri.resolveUri(uri);
|
||||
if (compiler == 'none' || scriptPath.endsWith('.js')) {
|
||||
Uri copiedScript = tempUri.resolveUri(uri);
|
||||
new File.fromUri(copiedScript).writeAsStringSync(
|
||||
new File.fromUri(script).readAsStringSync());
|
||||
} else {
|
||||
// TODO(21514): Compile scripts into output directory.
|
||||
Fail('HTML test scripts don\'t support dart2js yet');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
final Uri htmlFile = tempUri.resolve(filePath.filename);
|
||||
new File.fromUri(htmlFile).writeAsStringSync(contents);
|
||||
|
||||
var htmlPath = _createUrlPathFromFile(new Path(htmlFile.toFilePath()));
|
||||
var fullHtmlPath = _getUriForBrowserTest(info, htmlPath, null, null);
|
||||
var commands = [
|
||||
CommandBuilder.instance.getBrowserHtmlTestCommand(
|
||||
runtime,
|
||||
fullHtmlPath,
|
||||
configuration,
|
||||
info.expectedMessages)];
|
||||
String testDisplayName = '$suiteName/$testName';
|
||||
var testCase = new BrowserTestCase(
|
||||
testDisplayName,
|
||||
commands,
|
||||
configuration,
|
||||
expectations,
|
||||
info,
|
||||
isNegative(info),
|
||||
fullHtmlPath);
|
||||
enqueueNewTestCase(testCase);
|
||||
return;
|
||||
}
|
||||
|
||||
/** Helper to create a compilation command for a single input file. */
|
||||
|
|
Loading…
Reference in a new issue