OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /** | 5 /** |
6 * Classes and methods for enumerating and preparing tests. | 6 * Classes and methods for enumerating and preparing tests. |
7 * | 7 * |
8 * This library includes: | 8 * This library includes: |
9 * | 9 * |
10 * - Creating tests by listing all the Dart files in certain directories, | 10 * - Creating tests by listing all the Dart files in certain directories, |
11 * and creating [TestCase]s for those files that meet the relevant criteria. | 11 * and creating [TestCase]s for those files that meet the relevant criteria. |
12 * - Preparing tests, including copying files and frameworks to temporary | 12 * - Preparing tests, including copying files and frameworks to temporary |
13 * directories, and computing the command line and arguments to be run. | 13 * directories, and computing the command line and arguments to be run. |
14 */ | 14 */ |
15 import 'dart:async'; | 15 import 'dart:async'; |
16 import 'dart:io'; | 16 import 'dart:io'; |
17 | 17 |
18 import 'browser_test.dart'; | 18 import 'browser_test.dart'; |
| 19 import 'command.dart'; |
19 import 'compiler_configuration.dart'; | 20 import 'compiler_configuration.dart'; |
20 import 'configuration.dart'; | 21 import 'configuration.dart'; |
21 import 'drt_updater.dart'; | 22 import 'drt_updater.dart'; |
22 import 'expectation.dart'; | 23 import 'expectation.dart'; |
23 import 'expectation_set.dart'; | 24 import 'expectation_set.dart'; |
24 import 'html_test.dart' as html_test; | 25 import 'html_test.dart' as html_test; |
25 import 'http_server.dart'; | 26 import 'http_server.dart'; |
26 import 'multitest.dart'; | 27 import 'multitest.dart'; |
27 import 'path.dart'; | 28 import 'path.dart'; |
28 import 'summary_report.dart'; | 29 import 'summary_report.dart'; |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 | 469 |
469 var args = configuration.standardOptions.toList(); | 470 var args = configuration.standardOptions.toList(); |
470 if (configuration.compilerConfiguration.useDfe) { | 471 if (configuration.compilerConfiguration.useDfe) { |
471 args.add('--use-dart-frontend'); | 472 args.add('--use-dart-frontend'); |
472 // '--dfe' has to be the first argument for run_vm_test to pick it up. | 473 // '--dfe' has to be the first argument for run_vm_test to pick it up. |
473 args.insert(0, '--dfe=$buildDir/gen/kernel-service.dart.snapshot'); | 474 args.insert(0, '--dfe=$buildDir/gen/kernel-service.dart.snapshot'); |
474 } | 475 } |
475 | 476 |
476 args.add(testName); | 477 args.add(testName); |
477 | 478 |
478 var command = CommandBuilder.instance.getProcessCommand( | 479 var command = Command.process( |
479 'run_vm_unittest', targetRunnerPath, args, environmentOverrides); | 480 'run_vm_unittest', targetRunnerPath, args, environmentOverrides); |
480 enqueueNewTestCase( | 481 enqueueNewTestCase( |
481 new TestCase(constructedName, [command], configuration, expectations)); | 482 new TestCase(constructedName, [command], configuration, expectations)); |
482 } | 483 } |
483 | 484 |
484 Future<Null> forEachTest(Function onTest, Map testCache, | 485 Future<Null> forEachTest(Function onTest, Map testCache, |
485 [VoidFunction onDone]) async { | 486 [VoidFunction onDone]) async { |
486 doTest = onTest; | 487 doTest = onTest; |
487 var statusFiles = | 488 var statusFiles = |
488 statusFilePaths.map((statusFile) => "$dartDir/$statusFile").toList(); | 489 statusFilePaths.map((statusFile) => "$dartDir/$statusFile").toList(); |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
887 for (var name in otherResources) { | 888 for (var name in otherResources) { |
888 var namePath = new Path(name); | 889 var namePath = new Path(name); |
889 var fromPath = info.filePath.directoryPath.join(namePath); | 890 var fromPath = info.filePath.directoryPath.join(namePath); |
890 new File('$tempDir/$name').parent.createSync(recursive: true); | 891 new File('$tempDir/$name').parent.createSync(recursive: true); |
891 new File(fromPath.toNativePath()).copySync('$tempDir/$name'); | 892 new File(fromPath.toNativePath()).copySync('$tempDir/$name'); |
892 } | 893 } |
893 } | 894 } |
894 | 895 |
895 CommandArtifact compilationArtifact = | 896 CommandArtifact compilationArtifact = |
896 compilerConfiguration.computeCompilationArtifact( | 897 compilerConfiguration.computeCompilationArtifact( |
897 buildDir, | 898 buildDir, tempDir, compileTimeArguments, environmentOverrides); |
898 tempDir, | |
899 CommandBuilder.instance, | |
900 compileTimeArguments, | |
901 environmentOverrides); | |
902 if (!configuration.skipCompilation) { | 899 if (!configuration.skipCompilation) { |
903 commands.addAll(compilationArtifact.commands); | 900 commands.addAll(compilationArtifact.commands); |
904 } | 901 } |
905 | 902 |
906 if (expectCompileError(info) && compilerConfiguration.hasCompiler) { | 903 if (expectCompileError(info) && compilerConfiguration.hasCompiler) { |
907 // Do not attempt to run the compiled result. A compilation | 904 // Do not attempt to run the compiled result. A compilation |
908 // error should be reported by the compilation command. | 905 // error should be reported by the compilation command. |
909 return commands; | 906 return commands; |
910 } | 907 } |
911 | 908 |
912 List<String> runtimeArguments = | 909 List<String> runtimeArguments = |
913 compilerConfiguration.computeRuntimeArguments( | 910 compilerConfiguration.computeRuntimeArguments( |
914 configuration.runtimeConfiguration, | 911 configuration.runtimeConfiguration, |
915 buildDir, | 912 buildDir, |
916 info, | 913 info, |
917 vmOptions, | 914 vmOptions, |
918 sharedOptions, | 915 sharedOptions, |
919 args, | 916 args, |
920 compilationArtifact); | 917 compilationArtifact); |
921 | 918 |
922 return commands | 919 return commands |
923 ..addAll(configuration.runtimeConfiguration.computeRuntimeCommands( | 920 ..addAll(configuration.runtimeConfiguration.computeRuntimeCommands( |
924 this, | 921 this, compilationArtifact, runtimeArguments, environmentOverrides)); |
925 CommandBuilder.instance, | |
926 compilationArtifact, | |
927 runtimeArguments, | |
928 environmentOverrides)); | |
929 } | 922 } |
930 | 923 |
931 CreateTest makeTestCaseCreator(Map<String, dynamic> optionsFromFile) { | 924 CreateTest makeTestCaseCreator(Map<String, dynamic> optionsFromFile) { |
932 return (Path filePath, Path originTestPath, bool hasCompileError, | 925 return (Path filePath, Path originTestPath, bool hasCompileError, |
933 bool hasRuntimeError, | 926 bool hasRuntimeError, |
934 {bool isNegativeIfChecked: false, | 927 {bool isNegativeIfChecked: false, |
935 bool hasCompileErrorIfChecked: false, | 928 bool hasCompileErrorIfChecked: false, |
936 bool hasStaticWarning: false, | 929 bool hasStaticWarning: false, |
937 String multitestKey}) { | 930 String multitestKey}) { |
938 // Cache the test information for each test case. | 931 // Cache the test information for each test case. |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 | 1194 |
1202 if (configuration.compiler == Compiler.none) { | 1195 if (configuration.compiler == Compiler.none) { |
1203 dartFlags.add('--ignore-unrecognized-flags'); | 1196 dartFlags.add('--ignore-unrecognized-flags'); |
1204 if (configuration.isChecked) { | 1197 if (configuration.isChecked) { |
1205 dartFlags.add('--enable_asserts'); | 1198 dartFlags.add('--enable_asserts'); |
1206 dartFlags.add("--enable_type_checks"); | 1199 dartFlags.add("--enable_type_checks"); |
1207 } | 1200 } |
1208 dartFlags.addAll(vmOptions); | 1201 dartFlags.addAll(vmOptions); |
1209 } | 1202 } |
1210 | 1203 |
1211 commandSet.add(CommandBuilder.instance.getContentShellCommand( | 1204 commandSet.add(Command.contentShell(contentShellFilename, fullHtmlPath, |
1212 contentShellFilename, | 1205 contentShellOptions, dartFlags, environmentOverrides)); |
1213 fullHtmlPath, | |
1214 contentShellOptions, | |
1215 dartFlags, | |
1216 environmentOverrides)); | |
1217 } else { | 1206 } else { |
1218 commandSet.add(CommandBuilder.instance.getBrowserTestCommand( | 1207 commandSet.add(Command.browserTest(fullHtmlPath, configuration, |
1219 fullHtmlPath, configuration, !isNegative(info))); | 1208 retry: !isNegative(info))); |
1220 } | 1209 } |
1221 | 1210 |
1222 // Create BrowserTestCase and queue it. | 1211 // Create BrowserTestCase and queue it. |
1223 var fullTestName = multitest ? '$testName/$subtestName' : testName; | 1212 var fullTestName = multitest ? '$testName/$subtestName' : testName; |
1224 var expectation = (multitest ? expectations[fullTestName] : expectations) | 1213 var expectation = (multitest ? expectations[fullTestName] : expectations) |
1225 as Set<Expectation>; | 1214 as Set<Expectation>; |
1226 var testCase = new BrowserTestCase('$suiteName/$fullTestName', commandSet, | 1215 var testCase = new BrowserTestCase('$suiteName/$fullTestName', commandSet, |
1227 configuration, expectation, info, isNegative(info), fullHtmlPath); | 1216 configuration, expectation, info, isNegative(info), fullHtmlPath); |
1228 | 1217 |
1229 enqueueNewTestCase(testCase); | 1218 enqueueNewTestCase(testCase); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1288 script.toFilePath(), destination, tempDir, info.optionsFromFile)); | 1277 script.toFilePath(), destination, tempDir, info.optionsFromFile)); |
1289 } | 1278 } |
1290 } | 1279 } |
1291 } | 1280 } |
1292 | 1281 |
1293 var htmlFile = tempUri.resolve(filePath.filename); | 1282 var htmlFile = tempUri.resolve(filePath.filename); |
1294 new File.fromUri(htmlFile).writeAsStringSync(contents); | 1283 new File.fromUri(htmlFile).writeAsStringSync(contents); |
1295 | 1284 |
1296 var htmlPath = _createUrlPathFromFile(new Path(htmlFile.toFilePath())); | 1285 var htmlPath = _createUrlPathFromFile(new Path(htmlFile.toFilePath())); |
1297 var fullHtmlPath = _getUriForBrowserTest(htmlPath, null).toString(); | 1286 var fullHtmlPath = _getUriForBrowserTest(htmlPath, null).toString(); |
1298 commands.add(CommandBuilder.instance.getBrowserHtmlTestCommand( | 1287 commands.add(Command.browserHtmlTest( |
1299 fullHtmlPath, configuration, info.expectedMessages, !isNegative(info))); | 1288 fullHtmlPath, configuration, info.expectedMessages, |
| 1289 retry: !isNegative(info))); |
1300 var testDisplayName = '$suiteName/$testName'; | 1290 var testDisplayName = '$suiteName/$testName'; |
1301 var testCase = new BrowserTestCase(testDisplayName, commands, configuration, | 1291 var testCase = new BrowserTestCase(testDisplayName, commands, configuration, |
1302 expectations, info, isNegative(info), fullHtmlPath); | 1292 expectations, info, isNegative(info), fullHtmlPath); |
1303 enqueueNewTestCase(testCase); | 1293 enqueueNewTestCase(testCase); |
1304 } | 1294 } |
1305 | 1295 |
1306 /** Helper to create a compilation command for a single input file. */ | 1296 /** Helper to create a compilation command for a single input file. */ |
1307 Command _compileCommand(String inputFile, String outputFile, String dir, | 1297 Command _compileCommand(String inputFile, String outputFile, String dir, |
1308 Map<String, dynamic> optionsFromFile) { | 1298 Map<String, dynamic> optionsFromFile) { |
1309 var args = <String>[]; | 1299 var args = <String>[]; |
1310 | 1300 |
1311 if (compilerPath.endsWith('.dart')) { | 1301 if (compilerPath.endsWith('.dart')) { |
1312 // Run the compiler script via the Dart VM. | 1302 // Run the compiler script via the Dart VM. |
1313 args.add(compilerPath); | 1303 args.add(compilerPath); |
1314 } | 1304 } |
1315 | 1305 |
1316 args.addAll(configuration.standardOptions); | 1306 args.addAll(configuration.standardOptions); |
1317 | 1307 |
1318 var packages = packagesArgument(optionsFromFile['packageRoot'] as String, | 1308 var packages = packagesArgument(optionsFromFile['packageRoot'] as String, |
1319 optionsFromFile['packages'] as String); | 1309 optionsFromFile['packages'] as String); |
1320 if (packages != null) args.add(packages); | 1310 if (packages != null) args.add(packages); |
1321 | 1311 |
1322 args.add('--out=$outputFile'); | 1312 args.add('--out=$outputFile'); |
1323 args.add(inputFile); | 1313 args.add(inputFile); |
1324 | 1314 |
1325 var options = optionsFromFile['sharedOptions'] as List<String>; | 1315 var options = optionsFromFile['sharedOptions'] as List<String>; |
1326 if (options != null) args.addAll(options); | 1316 if (options != null) args.addAll(options); |
1327 | 1317 |
1328 return CommandBuilder.instance.getCompilationCommand( | 1318 return Command.compilation(Compiler.dart2js.name, outputFile, !useSdk, |
1329 Compiler.dart2js.name, | 1319 dart2JsBootstrapDependencies, compilerPath, args, environmentOverrides); |
1330 outputFile, | |
1331 !useSdk, | |
1332 dart2JsBootstrapDependencies, | |
1333 compilerPath, | |
1334 args, | |
1335 environmentOverrides); | |
1336 } | 1320 } |
1337 | 1321 |
1338 /** Helper to create a Polymer deploy command for a single HTML file. */ | 1322 /** Helper to create a Polymer deploy command for a single HTML file. */ |
1339 Command _polymerDeployCommand(String inputFile, String outputDir, | 1323 Command _polymerDeployCommand(String inputFile, String outputDir, |
1340 Map<String, dynamic> optionsFromFile) { | 1324 Map<String, dynamic> optionsFromFile) { |
1341 var args = <String>[]; | 1325 var args = <String>[]; |
1342 var packages = packagesArgument(optionsFromFile['packageRoot'] as String, | 1326 var packages = packagesArgument(optionsFromFile['packageRoot'] as String, |
1343 optionsFromFile['packages'] as String); | 1327 optionsFromFile['packages'] as String); |
1344 if (packages != null) args.add(packages); | 1328 if (packages != null) args.add(packages); |
1345 args | 1329 args |
1346 ..add('package:polymer/deploy.dart') | 1330 ..add('package:polymer/deploy.dart') |
1347 ..add('--test') | 1331 ..add('--test') |
1348 ..add(inputFile) | 1332 ..add(inputFile) |
1349 ..add('--out') | 1333 ..add('--out') |
1350 ..add(outputDir) | 1334 ..add(outputDir) |
1351 ..add('--file-filter') | 1335 ..add('--file-filter') |
1352 ..add('.svn'); | 1336 ..add('.svn'); |
1353 if (configuration.isCsp) args.add('--csp'); | 1337 if (configuration.isCsp) args.add('--csp'); |
1354 | 1338 |
1355 return CommandBuilder.instance.getProcessCommand( | 1339 return Command.process( |
1356 'polymer_deploy', dartVmBinaryFileName, args, environmentOverrides); | 1340 'polymer_deploy', dartVmBinaryFileName, args, environmentOverrides); |
1357 } | 1341 } |
1358 | 1342 |
1359 String get scriptType { | 1343 String get scriptType { |
1360 switch (configuration.compiler) { | 1344 switch (configuration.compiler) { |
1361 case Compiler.none: | 1345 case Compiler.none: |
1362 return 'application/dart'; | 1346 return 'application/dart'; |
1363 case Compiler.dart2js: | 1347 case Compiler.dart2js: |
1364 case Compiler.dart2analyzer: | 1348 case Compiler.dart2analyzer: |
1365 return 'text/javascript'; | 1349 return 'text/javascript'; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1729 var customHtmlPath = dir.append('$nameNoExt.html'); | 1713 var customHtmlPath = dir.append('$nameNoExt.html'); |
1730 var customHtml = new File(customHtmlPath.toNativePath()); | 1714 var customHtml = new File(customHtmlPath.toNativePath()); |
1731 if (!customHtml.existsSync()) { | 1715 if (!customHtml.existsSync()) { |
1732 super.enqueueBrowserTest( | 1716 super.enqueueBrowserTest( |
1733 packageRoot, packages, info, testName, expectations); | 1717 packageRoot, packages, info, testName, expectations); |
1734 } else { | 1718 } else { |
1735 var relativeHtml = customHtmlPath.relativeTo(TestUtils.dartDir); | 1719 var relativeHtml = customHtmlPath.relativeTo(TestUtils.dartDir); |
1736 var fullPath = _createUrlPathFromFile(customHtmlPath); | 1720 var fullPath = _createUrlPathFromFile(customHtmlPath); |
1737 | 1721 |
1738 var commands = [ | 1722 var commands = [ |
1739 CommandBuilder.instance | 1723 Command.browserTest(fullPath, configuration, retry: !isNegative(info)) |
1740 .getBrowserTestCommand(fullPath, configuration, !isNegative(info)) | |
1741 ]; | 1724 ]; |
1742 var testDisplayName = '$suiteName/$testName'; | 1725 var testDisplayName = '$suiteName/$testName'; |
1743 enqueueNewTestCase(new BrowserTestCase( | 1726 enqueueNewTestCase(new BrowserTestCase( |
1744 testDisplayName, | 1727 testDisplayName, |
1745 commands, | 1728 commands, |
1746 configuration, | 1729 configuration, |
1747 expectations as Set<Expectation>, | 1730 expectations as Set<Expectation>, |
1748 info, | 1731 info, |
1749 isNegative(info), | 1732 isNegative(info), |
1750 relativeHtml.toNativePath())); | 1733 relativeHtml.toNativePath())); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1801 | 1784 |
1802 bool isTestFile(String filename) { | 1785 bool isTestFile(String filename) { |
1803 // NOTE: We exclude tests and patch files for now. | 1786 // NOTE: We exclude tests and patch files for now. |
1804 return filename.endsWith(".dart") && | 1787 return filename.endsWith(".dart") && |
1805 !filename.endsWith("_test.dart") && | 1788 !filename.endsWith("_test.dart") && |
1806 !filename.contains("_internal/js_runtime/lib"); | 1789 !filename.contains("_internal/js_runtime/lib"); |
1807 } | 1790 } |
1808 | 1791 |
1809 bool get listRecursively => true; | 1792 bool get listRecursively => true; |
1810 } | 1793 } |
OLD | NEW |