| 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, |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 String createPubspecCheckoutDirectory(Path directoryOfPubspecYaml) { | 408 String createPubspecCheckoutDirectory(Path directoryOfPubspecYaml) { |
| 409 var sdk = configuration['use_sdk'] ? 'sdk' : ''; | 409 var sdk = configuration['use_sdk'] ? 'sdk' : ''; |
| 410 return createGeneratedTestDirectoryHelper( | 410 return createGeneratedTestDirectoryHelper( |
| 411 "pubspec_checkouts", sdk, directoryOfPubspecYaml, ""); | 411 "pubspec_checkouts", sdk, directoryOfPubspecYaml, ""); |
| 412 } | 412 } |
| 413 | 413 |
| 414 String createPubPackageBuildsDirectory(Path directoryOfPubspecYaml) { | 414 String createPubPackageBuildsDirectory(Path directoryOfPubspecYaml) { |
| 415 return createGeneratedTestDirectoryHelper( | 415 return createGeneratedTestDirectoryHelper( |
| 416 "pub_package_builds", 'public_packages', directoryOfPubspecYaml, ""); | 416 "pub_package_builds", 'public_packages', directoryOfPubspecYaml, ""); |
| 417 } | 417 } |
| 418 | |
| 419 /** | |
| 420 * Helper function for discovering the packages in the dart repository. | |
| 421 */ | |
| 422 Future<List> listDir(Path path, Function isValid) { | |
| 423 var dir = new Directory(path.toNativePath()); | |
| 424 return dir.exists().then((exists) { | |
| 425 if (!exists) return []; | |
| 426 return dir | |
| 427 .list(recursive: false) | |
| 428 .where((fse) => fse is Directory) | |
| 429 .map((FileSystemEntity entity) { | |
| 430 var directory = entity as Directory; | |
| 431 var fullPath = directory.absolute.path; | |
| 432 var packageName = new Path(fullPath).filename; | |
| 433 if (isValid(packageName)) { | |
| 434 return [packageName, path.append(packageName).toNativePath()]; | |
| 435 } | |
| 436 return null; | |
| 437 }) | |
| 438 .where((name) => name != null) | |
| 439 .toList(); | |
| 440 }); | |
| 441 } | |
| 442 } | 418 } |
| 443 | 419 |
| 444 Future<Iterable<String>> ccTestLister(String runnerPath) { | 420 Future<Iterable<String>> ccTestLister(String runnerPath) { |
| 445 return Process.run(runnerPath, ["--list"]).then((ProcessResult result) { | 421 return Process.run(runnerPath, ["--list"]).then((ProcessResult result) { |
| 446 if (result.exitCode != 0) { | 422 if (result.exitCode != 0) { |
| 447 throw "Failed to list tests: '$runnerPath --list'. " | 423 throw "Failed to list tests: '$runnerPath --list'. " |
| 448 "Process exited with ${result.exitCode}"; | 424 "Process exited with ${result.exitCode}"; |
| 449 } | 425 } |
| 450 return result.stdout | 426 return result.stdout |
| 451 .split('\n') | 427 .split('\n') |
| 452 .map((line) => line.trim()) | 428 .map((line) => line.trim()) |
| 453 .where((name) => name.length > 0); | 429 .where((name) => name.isNotEmpty); |
| 454 }); | 430 }); |
| 455 } | 431 } |
| 456 | 432 |
| 457 /** | 433 /** |
| 458 * A specialized [TestSuite] that runs tests written in C to unit test | 434 * A specialized [TestSuite] that runs tests written in C to unit test |
| 459 * the Dart virtual machine and its API. | 435 * the Dart virtual machine and its API. |
| 460 * | 436 * |
| 461 * The tests are compiled into a monolithic executable by the build step. | 437 * The tests are compiled into a monolithic executable by the build step. |
| 462 * The executable lists its tests when run with the --list command line flag. | 438 * The executable lists its tests when run with the --list command line flag. |
| 463 * Individual tests are run by specifying them on the command line. | 439 * Individual tests are run by specifying them on the command line. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 * directory, and creates [TestCase]s that compile and/or run them. | 545 * directory, and creates [TestCase]s that compile and/or run them. |
| 570 */ | 546 */ |
| 571 class StandardTestSuite extends TestSuite { | 547 class StandardTestSuite extends TestSuite { |
| 572 final Path suiteDir; | 548 final Path suiteDir; |
| 573 final List<String> statusFilePaths; | 549 final List<String> statusFilePaths; |
| 574 TestExpectations testExpectations; | 550 TestExpectations testExpectations; |
| 575 List<TestInformation> cachedTests; | 551 List<TestInformation> cachedTests; |
| 576 final Path dartDir; | 552 final Path dartDir; |
| 577 Predicate<String> isTestFilePredicate; | 553 Predicate<String> isTestFilePredicate; |
| 578 final bool listRecursively; | 554 final bool listRecursively; |
| 579 final extraVmOptions; | 555 final List<String> extraVmOptions; |
| 580 List<Uri> _dart2JsBootstrapDependencies; | 556 List<Uri> _dart2JsBootstrapDependencies; |
| 581 | 557 |
| 582 StandardTestSuite(Map configuration, String suiteName, Path suiteDirectory, | 558 StandardTestSuite(Map configuration, String suiteName, Path suiteDirectory, |
| 583 this.statusFilePaths, | 559 this.statusFilePaths, |
| 584 {this.isTestFilePredicate, bool recursive: false}) | 560 {this.isTestFilePredicate, bool recursive: false}) |
| 585 : dartDir = TestUtils.dartDir, | 561 : dartDir = TestUtils.dartDir, |
| 586 listRecursively = recursive, | 562 listRecursively = recursive, |
| 587 suiteDir = TestUtils.dartDir.join(suiteDirectory), | 563 suiteDir = TestUtils.dartDir.join(suiteDirectory), |
| 588 extraVmOptions = TestUtils.getExtraVmOptions(configuration), | 564 extraVmOptions = TestUtils.getExtraVmOptions(configuration), |
| 589 super(configuration, suiteName) { | 565 super(configuration, suiteName) { |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 | 635 |
| 660 List<String> additionalOptions(Path filePath) => []; | 636 List<String> additionalOptions(Path filePath) => []; |
| 661 | 637 |
| 662 forEachTest(Function onTest, Map testCache, [VoidFunction onDone]) async { | 638 forEachTest(Function onTest, Map testCache, [VoidFunction onDone]) async { |
| 663 await updateDartium(); | 639 await updateDartium(); |
| 664 doTest = onTest; | 640 doTest = onTest; |
| 665 testExpectations = await readExpectations(); | 641 testExpectations = await readExpectations(); |
| 666 | 642 |
| 667 // Check if we have already found and generated the tests for this suite. | 643 // Check if we have already found and generated the tests for this suite. |
| 668 if (!testCache.containsKey(suiteName)) { | 644 if (!testCache.containsKey(suiteName)) { |
| 669 cachedTests = testCache[suiteName] = []; | 645 cachedTests = testCache[suiteName] = <TestInformation>[]; |
| 670 await enqueueTests(); | 646 await enqueueTests(); |
| 671 } else { | 647 } else { |
| 672 for (var info in testCache[suiteName]) { | 648 for (var info in testCache[suiteName]) { |
| 673 enqueueTestCaseFromTestInformation(info); | 649 enqueueTestCaseFromTestInformation(info); |
| 674 } | 650 } |
| 675 } | 651 } |
| 676 testExpectations = null; | 652 testExpectations = null; |
| 677 cachedTests = null; | 653 cachedTests = null; |
| 678 doTest = null; | 654 doTest = null; |
| 679 if (onDone != null) onDone(); | 655 if (onDone != null) onDone(); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 } | 819 } |
| 844 | 820 |
| 845 void enqueueStandardTest(List<Command> baseCommands, TestInformation info, | 821 void enqueueStandardTest(List<Command> baseCommands, TestInformation info, |
| 846 String testName, Set<Expectation> expectations) { | 822 String testName, Set<Expectation> expectations) { |
| 847 var commonArguments = | 823 var commonArguments = |
| 848 commonArgumentsFromFile(info.filePath, info.optionsFromFile); | 824 commonArgumentsFromFile(info.filePath, info.optionsFromFile); |
| 849 | 825 |
| 850 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); | 826 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); |
| 851 assert(!vmOptionsList.isEmpty); | 827 assert(!vmOptionsList.isEmpty); |
| 852 | 828 |
| 853 for (var vmOptionsVarient = 0; | 829 for (var vmOptionsVariant = 0; |
| 854 vmOptionsVarient < vmOptionsList.length; | 830 vmOptionsVariant < vmOptionsList.length; |
| 855 vmOptionsVarient++) { | 831 vmOptionsVariant++) { |
| 856 var vmOptions = vmOptionsList[vmOptionsVarient]; | 832 var vmOptions = vmOptionsList[vmOptionsVariant]; |
| 857 var allVmOptions = vmOptions; | 833 var allVmOptions = vmOptions; |
| 858 if (!extraVmOptions.isEmpty) { | 834 if (!extraVmOptions.isEmpty) { |
| 859 allVmOptions = new List.from(vmOptions)..addAll(extraVmOptions); | 835 allVmOptions = new List.from(vmOptions)..addAll(extraVmOptions); |
| 860 } | 836 } |
| 861 | 837 |
| 862 var commands = baseCommands.toList(); | 838 var commands = baseCommands.toList(); |
| 863 commands.addAll( | 839 commands.addAll( |
| 864 makeCommands(info, vmOptionsVarient, allVmOptions, commonArguments)); | 840 makeCommands(info, vmOptionsVariant, allVmOptions, commonArguments)); |
| 865 enqueueNewTestCase(new TestCase( | 841 enqueueNewTestCase(new TestCase( |
| 866 '$suiteName/$testName', commands, configuration, expectations, | 842 '$suiteName/$testName', commands, configuration, expectations, |
| 867 isNegative: isNegative(info), info: info)); | 843 isNegative: isNegative(info), info: info)); |
| 868 } | 844 } |
| 869 } | 845 } |
| 870 | 846 |
| 871 bool expectCompileError(TestInformation info) { | 847 bool expectCompileError(TestInformation info) { |
| 872 return info.hasCompileError || | 848 return info.hasCompileError || |
| 873 (configuration['checked'] && info.hasCompileErrorIfChecked); | 849 (configuration['checked'] && info.hasCompileErrorIfChecked); |
| 874 } | 850 } |
| 875 | 851 |
| 876 bool isNegative(TestInformation info) { | 852 bool isNegative(TestInformation info) { |
| 877 bool negative = expectCompileError(info) || | 853 bool negative = expectCompileError(info) || |
| 878 (configuration['checked'] && info.isNegativeIfChecked); | 854 (configuration['checked'] && info.isNegativeIfChecked); |
| 879 if (info.hasRuntimeError && hasRuntime) { | 855 if (info.hasRuntimeError && hasRuntime) { |
| 880 negative = true; | 856 negative = true; |
| 881 } | 857 } |
| 882 return negative; | 858 return negative; |
| 883 } | 859 } |
| 884 | 860 |
| 885 List<Command> makeCommands( | 861 List<Command> makeCommands(TestInformation info, int vmOptionsVarient, |
| 886 TestInformation info, int vmOptionsVarient, var vmOptions, var args) { | 862 List<String> vmOptions, List<String> args) { |
| 887 List<Command> commands = <Command>[]; | 863 var commands = <Command>[]; |
| 888 CompilerConfiguration compilerConfiguration = | 864 var compilerConfiguration = new CompilerConfiguration(configuration); |
| 889 new CompilerConfiguration(configuration); | |
| 890 List<String> sharedOptions = info.optionsFromFile['sharedOptions']; | 865 List<String> sharedOptions = info.optionsFromFile['sharedOptions']; |
| 891 | 866 |
| 892 List<String> compileTimeArguments = <String>[]; | 867 var compileTimeArguments = <String>[]; |
| 893 String tempDir; | 868 String tempDir; |
| 894 if (compilerConfiguration.hasCompiler) { | 869 if (compilerConfiguration.hasCompiler) { |
| 895 compileTimeArguments = compilerConfiguration.computeCompilerArguments( | 870 compileTimeArguments = compilerConfiguration.computeCompilerArguments( |
| 896 vmOptions, sharedOptions, args); | 871 vmOptions, sharedOptions, args); |
| 897 // Avoid doing this for analyzer. | 872 // Avoid doing this for analyzer. |
| 898 var path = info.filePath; | 873 var path = info.filePath; |
| 899 if (vmOptionsVarient != 0) { | 874 if (vmOptionsVarient != 0) { |
| 900 // Ensure a unique directory for each test case. | 875 // Ensure a unique directory for each test case. |
| 901 path = path.join(new Path(vmOptionsVarient.toString())); | 876 path = path.join(new Path(vmOptionsVarient.toString())); |
| 902 } | 877 } |
| 903 tempDir = createCompilationOutputDirectory(path); | 878 tempDir = createCompilationOutputDirectory(path); |
| 904 | 879 |
| 905 List<String> otherResources = info.optionsFromFile['otherResources']; | 880 List<String> otherResources = info.optionsFromFile['otherResources']; |
| 906 for (String name in otherResources) { | 881 for (var name in otherResources) { |
| 907 Path namePath = new Path(name); | 882 var namePath = new Path(name); |
| 908 Path fromPath = info.filePath.directoryPath.join(namePath); | 883 var fromPath = info.filePath.directoryPath.join(namePath); |
| 909 new File('$tempDir/$name').parent.createSync(recursive: true); | 884 new File('$tempDir/$name').parent.createSync(recursive: true); |
| 910 new File(fromPath.toNativePath()).copySync('$tempDir/$name'); | 885 new File(fromPath.toNativePath()).copySync('$tempDir/$name'); |
| 911 } | 886 } |
| 912 } | 887 } |
| 913 | 888 |
| 914 CommandArtifact compilationArtifact = | 889 CommandArtifact compilationArtifact = |
| 915 compilerConfiguration.computeCompilationArtifact( | 890 compilerConfiguration.computeCompilationArtifact( |
| 916 buildDir, | 891 buildDir, |
| 917 tempDir, | 892 tempDir, |
| 918 CommandBuilder.instance, | 893 CommandBuilder.instance, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 * JavaScript. This function creates a working directory to hold the | 1012 * JavaScript. This function creates a working directory to hold the |
| 1038 * JavaScript version of the test, and copies the appropriate framework | 1013 * JavaScript version of the test, and copies the appropriate framework |
| 1039 * files to that directory. It creates a [BrowserTestCase], which has | 1014 * files to that directory. It creates a [BrowserTestCase], which has |
| 1040 * two sequential steps to be run by the [ProcessQueue] when the test is | 1015 * two sequential steps to be run by the [ProcessQueue] when the test is |
| 1041 * executed: a compilation step and an execution step, both with the | 1016 * executed: a compilation step and an execution step, both with the |
| 1042 * appropriate executable and arguments. The [expectations] object can be | 1017 * appropriate executable and arguments. The [expectations] object can be |
| 1043 * either a Set<String> if the test is a regular test, or a Map<String | 1018 * either a Set<String> if the test is a regular test, or a Map<String |
| 1044 * subTestName, Set<String>> if we are running a browser multi-test (one | 1019 * subTestName, Set<String>> if we are running a browser multi-test (one |
| 1045 * compilation and many browser runs). | 1020 * compilation and many browser runs). |
| 1046 */ | 1021 */ |
| 1047 void enqueueBrowserTest(List<Command> baseCommands, Path packageRoot, | 1022 void enqueueBrowserTest( |
| 1048 Path packages, TestInformation info, String testName, expectations) { | 1023 List<Command> baseCommands, |
| 1024 Path packageRoot, |
| 1025 Path packages, |
| 1026 TestInformation info, |
| 1027 String testName, |
| 1028 /* Set<Expectation> | Map<String, Set<Expectation>> */ dynamic |
| 1029 expectations) { |
| 1049 RegExp badChars = new RegExp('[-=/]'); | 1030 RegExp badChars = new RegExp('[-=/]'); |
| 1050 List VmOptionsList = getVmOptions(info.optionsFromFile); | 1031 List VmOptionsList = getVmOptions(info.optionsFromFile); |
| 1051 bool multipleOptions = VmOptionsList.length > 1; | 1032 bool multipleOptions = VmOptionsList.length > 1; |
| 1052 for (var vmOptions in VmOptionsList) { | 1033 for (var vmOptions in VmOptionsList) { |
| 1053 String optionsName = | 1034 String optionsName = |
| 1054 multipleOptions ? vmOptions.join('-').replaceAll(badChars, '') : ''; | 1035 multipleOptions ? vmOptions.join('-').replaceAll(badChars, '') : ''; |
| 1055 String tempDir = createOutputDirectory(info.filePath, optionsName); | 1036 String tempDir = createOutputDirectory(info.filePath, optionsName); |
| 1056 enqueueBrowserTestWithOptions(baseCommands, packageRoot, packages, info, | 1037 enqueueBrowserTestWithOptions(baseCommands, packageRoot, packages, info, |
| 1057 testName, expectations, vmOptions, tempDir); | 1038 testName, expectations, vmOptions, tempDir); |
| 1058 } | 1039 } |
| 1059 } | 1040 } |
| 1060 | 1041 |
| 1061 void enqueueBrowserTestWithOptions( | 1042 void enqueueBrowserTestWithOptions( |
| 1062 List<Command> baseCommands, | 1043 List<Command> baseCommands, |
| 1063 Path packageRoot, | 1044 Path packageRoot, |
| 1064 Path packages, | 1045 Path packages, |
| 1065 TestInformation info, | 1046 TestInformation info, |
| 1066 String testName, | 1047 String testName, |
| 1067 expectations, | 1048 /* Set<Expectation> | Map<String, Set<Expectation>> */ expectations, |
| 1068 List<String> vmOptions, | 1049 List<String> vmOptions, |
| 1069 String tempDir) { | 1050 String tempDir) { |
| 1070 // TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot] | 1051 // TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot] |
| 1071 // on to the browser (it may be test specific). | 1052 // on to the browser (it may be test specific). |
| 1072 | 1053 |
| 1073 Path filePath = info.filePath; | 1054 Path filePath = info.filePath; |
| 1074 String filename = filePath.toString(); | 1055 String filename = filePath.toString(); |
| 1075 | 1056 |
| 1076 final String compiler = configuration['compiler']; | 1057 final String compiler = configuration['compiler']; |
| 1077 final String runtime = configuration['runtime']; | 1058 final String runtime = configuration['runtime']; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 // Create BrowserTestCase and queue it. | 1215 // Create BrowserTestCase and queue it. |
| 1235 var fullTestName = multitest ? '$testName/$subtestName' : testName; | 1216 var fullTestName = multitest ? '$testName/$subtestName' : testName; |
| 1236 var expectation = multitest ? expectations[fullTestName] : expectations; | 1217 var expectation = multitest ? expectations[fullTestName] : expectations; |
| 1237 var testCase = new BrowserTestCase('$suiteName/$fullTestName', commandSet, | 1218 var testCase = new BrowserTestCase('$suiteName/$fullTestName', commandSet, |
| 1238 configuration, expectation, info, isNegative(info), fullHtmlPath); | 1219 configuration, expectation, info, isNegative(info), fullHtmlPath); |
| 1239 | 1220 |
| 1240 enqueueNewTestCase(testCase); | 1221 enqueueNewTestCase(testCase); |
| 1241 } | 1222 } |
| 1242 } | 1223 } |
| 1243 | 1224 |
| 1244 void enqueueHtmlTest( | 1225 void enqueueHtmlTest(HtmlTestInformation info, String testName, |
| 1245 HtmlTestInformation info, String testName, expectations) { | 1226 Set<Expectation> expectations) { |
| 1246 final String compiler = configuration['compiler']; | 1227 final String compiler = configuration['compiler']; |
| 1247 final String runtime = configuration['runtime']; | 1228 final String runtime = configuration['runtime']; |
| 1248 // Html tests work only with the browser controller. | 1229 // Html tests work only with the browser controller. |
| 1249 if (!TestUtils.isBrowserRuntime(runtime) || runtime == 'drt') { | 1230 if (!TestUtils.isBrowserRuntime(runtime) || runtime == 'drt') { |
| 1250 return; | 1231 return; |
| 1251 } | 1232 } |
| 1252 bool compileToJS = (compiler == 'dart2js'); | 1233 bool compileToJS = (compiler == 'dart2js'); |
| 1253 | 1234 |
| 1254 final Path filePath = info.filePath; | 1235 final Path filePath = info.filePath; |
| 1255 final String tempDir = createOutputDirectory(filePath, ''); | 1236 final String tempDir = createOutputDirectory(filePath, ''); |
| 1256 final Uri tempUri = new Uri.file('$tempDir/'); | 1237 final Uri tempUri = new Uri.file('$tempDir/'); |
| 1257 String contents = htmlTest.getContents(info, compileToJS); | 1238 String contents = htmlTest.getContents(info, compileToJS); |
| 1258 final commands = []; | 1239 final commands = <Command>[]; |
| 1259 | 1240 |
| 1260 void Fail(String message) { | 1241 void Fail(String message) { |
| 1261 var msg = "$message: ${info.filePath}"; | 1242 var msg = "$message: ${info.filePath}"; |
| 1262 DebugLogger.warning(msg); | 1243 DebugLogger.warning(msg); |
| 1263 contents = htmlTest.makeFailingHtmlFile(msg); | 1244 contents = htmlTest.makeFailingHtmlFile(msg); |
| 1264 } | 1245 } |
| 1265 | 1246 |
| 1266 if (info.scripts.length > 0) { | 1247 if (info.scripts.length > 0) { |
| 1267 Uri testUri = new Uri.file(filePath.toNativePath()); | 1248 Uri testUri = new Uri.file(filePath.toNativePath()); |
| 1268 for (String scriptPath in info.scripts) { | 1249 for (String scriptPath in info.scripts) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1303 fullHtmlPath, configuration, info.expectedMessages, !isNegative(info))); | 1284 fullHtmlPath, configuration, info.expectedMessages, !isNegative(info))); |
| 1304 String testDisplayName = '$suiteName/$testName'; | 1285 String testDisplayName = '$suiteName/$testName'; |
| 1305 var testCase = new BrowserTestCase(testDisplayName, commands, configuration, | 1286 var testCase = new BrowserTestCase(testDisplayName, commands, configuration, |
| 1306 expectations, info, isNegative(info), fullHtmlPath); | 1287 expectations, info, isNegative(info), fullHtmlPath); |
| 1307 enqueueNewTestCase(testCase); | 1288 enqueueNewTestCase(testCase); |
| 1308 return; | 1289 return; |
| 1309 } | 1290 } |
| 1310 | 1291 |
| 1311 /** Helper to create a compilation command for a single input file. */ | 1292 /** Helper to create a compilation command for a single input file. */ |
| 1312 Command _compileCommand(String inputFile, String outputFile, String compiler, | 1293 Command _compileCommand(String inputFile, String outputFile, String compiler, |
| 1313 String dir, optionsFromFile) { | 1294 String dir, Map optionsFromFile) { |
| 1314 assert(compiler == 'dart2js'); | 1295 assert(compiler == 'dart2js'); |
| 1315 List<String> args; | 1296 List<String> args; |
| 1316 if (compilerPath.endsWith('.dart')) { | 1297 if (compilerPath.endsWith('.dart')) { |
| 1317 // Run the compiler script via the Dart VM. | 1298 // Run the compiler script via the Dart VM. |
| 1318 args = [compilerPath]; | 1299 args = [compilerPath]; |
| 1319 } else { | 1300 } else { |
| 1320 args = []; | 1301 args = []; |
| 1321 } | 1302 } |
| 1322 args.addAll(TestUtils.standardOptions(configuration)); | 1303 args.addAll(TestUtils.standardOptions(configuration)); |
| 1323 String packages = packagesArgument( | 1304 String packages = packagesArgument( |
| 1324 optionsFromFile['packageRoot'], optionsFromFile['packages']); | 1305 optionsFromFile['packageRoot'], optionsFromFile['packages']); |
| 1325 if (packages != null) args.add(packages); | 1306 if (packages != null) args.add(packages); |
| 1326 args.add('--out=$outputFile'); | 1307 args.add('--out=$outputFile'); |
| 1327 args.add(inputFile); | 1308 args.add(inputFile); |
| 1328 List<String> options = optionsFromFile['sharedOptions']; | 1309 List<String> options = optionsFromFile['sharedOptions']; |
| 1329 if (options != null) args.addAll(options); | 1310 if (options != null) args.addAll(options); |
| 1330 return CommandBuilder.instance.getCompilationCommand( | 1311 return CommandBuilder.instance.getCompilationCommand( |
| 1331 compiler, | 1312 compiler, |
| 1332 outputFile, | 1313 outputFile, |
| 1333 !useSdk, | 1314 !useSdk, |
| 1334 dart2JsBootstrapDependencies, | 1315 dart2JsBootstrapDependencies, |
| 1335 compilerPath, | 1316 compilerPath, |
| 1336 args, | 1317 args, |
| 1337 environmentOverrides); | 1318 environmentOverrides); |
| 1338 } | 1319 } |
| 1339 | 1320 |
| 1340 /** Helper to create a Polymer deploy command for a single HTML file. */ | 1321 /** Helper to create a Polymer deploy command for a single HTML file. */ |
| 1341 Command _polymerDeployCommand( | 1322 Command _polymerDeployCommand( |
| 1342 String inputFile, String outputDir, optionsFromFile) { | 1323 String inputFile, String outputDir, Map optionsFromFile) { |
| 1343 List<String> args = []; | 1324 List<String> args = []; |
| 1344 String packages = packagesArgument( | 1325 String packages = packagesArgument( |
| 1345 optionsFromFile['packageRoot'], optionsFromFile['packages']); | 1326 optionsFromFile['packageRoot'], optionsFromFile['packages']); |
| 1346 if (packages != null) args.add(packages); | 1327 if (packages != null) args.add(packages); |
| 1347 args | 1328 args |
| 1348 ..add('package:polymer/deploy.dart') | 1329 ..add('package:polymer/deploy.dart') |
| 1349 ..add('--test') | 1330 ..add('--test') |
| 1350 ..add(inputFile) | 1331 ..add(inputFile) |
| 1351 ..add('--out') | 1332 ..add('--out') |
| 1352 ..add(outputDir) | 1333 ..add(outputDir) |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1520 // TODO(gram) Clean these up once the old directives are not supported. | 1501 // TODO(gram) Clean these up once the old directives are not supported. |
| 1521 RegExp domImportRegExp = new RegExp( | 1502 RegExp domImportRegExp = new RegExp( |
| 1522 r"^[#]?import.*dart:(html|web_audio|indexed_db|svg|web_sql)", | 1503 r"^[#]?import.*dart:(html|web_audio|indexed_db|svg|web_sql)", |
| 1523 multiLine: true); | 1504 multiLine: true); |
| 1524 | 1505 |
| 1525 var bytes = new File(filePath.toNativePath()).readAsBytesSync(); | 1506 var bytes = new File(filePath.toNativePath()).readAsBytesSync(); |
| 1526 String contents = decodeUtf8(bytes); | 1507 String contents = decodeUtf8(bytes); |
| 1527 bytes = null; | 1508 bytes = null; |
| 1528 | 1509 |
| 1529 // Find the options in the file. | 1510 // Find the options in the file. |
| 1530 List<List> result = new List<List>(); | 1511 var result = <List<String>>[]; |
| 1531 List<String> dartOptions; | 1512 List<String> dartOptions; |
| 1532 List<String> sharedOptions; | 1513 List<String> sharedOptions; |
| 1533 String packageRoot; | 1514 String packageRoot; |
| 1534 String packages; | 1515 String packages; |
| 1535 | 1516 |
| 1536 Iterable<Match> matches = testOptionsRegExp.allMatches(contents); | 1517 Iterable<Match> matches = testOptionsRegExp.allMatches(contents); |
| 1537 for (var match in matches) { | 1518 for (var match in matches) { |
| 1538 result.add(match[1].split(' ').where((e) => e != '').toList()); | 1519 result.add(match[1].split(' ').where((e) => e != '').toList()); |
| 1539 } | 1520 } |
| 1540 if (result.isEmpty) result.add([]); | 1521 if (result.isEmpty) result.add([]); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1658 'dart_precompiled', | 1639 'dart_precompiled', |
| 1659 'vm', | 1640 'vm', |
| 1660 'drt', | 1641 'drt', |
| 1661 'dartium', | 1642 'dartium', |
| 1662 'ContentShellOnAndroid', | 1643 'ContentShellOnAndroid', |
| 1663 'DartiumOnAndroid' | 1644 'DartiumOnAndroid' |
| 1664 ]; | 1645 ]; |
| 1665 var needsVmOptions = COMPILERS.contains(configuration['compiler']) && | 1646 var needsVmOptions = COMPILERS.contains(configuration['compiler']) && |
| 1666 RUNTIMES.contains(configuration['runtime']); | 1647 RUNTIMES.contains(configuration['runtime']); |
| 1667 if (!needsVmOptions) return [[]]; | 1648 if (!needsVmOptions) return [[]]; |
| 1668 final vmOptions = optionsFromFile['vmOptions']; | 1649 return optionsFromFile['vmOptions']; |
| 1669 return vmOptions; | |
| 1670 } | 1650 } |
| 1671 | 1651 |
| 1672 /** | 1652 /** |
| 1673 * Read options from a co19 test file. | 1653 * Read options from a co19 test file. |
| 1674 * | 1654 * |
| 1675 * The reason this is different from [readOptionsFromFile] is that | 1655 * The reason this is different from [readOptionsFromFile] is that |
| 1676 * co19 is developed based on a contract which defines certain test | 1656 * co19 is developed based on a contract which defines certain test |
| 1677 * tags. These tags may appear unused, but should not be removed | 1657 * tags. These tags may appear unused, but should not be removed |
| 1678 * without consulting with the co19 team. | 1658 * without consulting with the co19 team. |
| 1679 * | 1659 * |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 | 1693 |
| 1714 /// Used for testing packages in on off settings, i.e., we pass in the actual | 1694 /// Used for testing packages in on off settings, i.e., we pass in the actual |
| 1715 /// directory that we want to test. | 1695 /// directory that we want to test. |
| 1716 class PKGTestSuite extends StandardTestSuite { | 1696 class PKGTestSuite extends StandardTestSuite { |
| 1717 PKGTestSuite(Map configuration, Path directoryPath) | 1697 PKGTestSuite(Map configuration, Path directoryPath) |
| 1718 : super(configuration, directoryPath.filename, directoryPath, | 1698 : super(configuration, directoryPath.filename, directoryPath, |
| 1719 ["$directoryPath/.status"], | 1699 ["$directoryPath/.status"], |
| 1720 isTestFilePredicate: (f) => f.endsWith('_test.dart'), | 1700 isTestFilePredicate: (f) => f.endsWith('_test.dart'), |
| 1721 recursive: true); | 1701 recursive: true); |
| 1722 | 1702 |
| 1723 void enqueueBrowserTest(List<Command> baseCommands, Path packageRoot, | 1703 void enqueueBrowserTest( |
| 1724 packages, TestInformation info, String testName, expectations) { | 1704 List<Command> baseCommands, |
| 1705 Path packageRoot, |
| 1706 packages, |
| 1707 TestInformation info, |
| 1708 String testName, |
| 1709 /* Set<Expectation> | Map<String, Set<Expectation>> */ dynamic |
| 1710 expectations) { |
| 1725 String runtime = configuration['runtime']; | 1711 String runtime = configuration['runtime']; |
| 1726 Path filePath = info.filePath; | 1712 Path filePath = info.filePath; |
| 1727 Path dir = filePath.directoryPath; | 1713 Path dir = filePath.directoryPath; |
| 1728 String nameNoExt = filePath.filenameWithoutExtension; | 1714 String nameNoExt = filePath.filenameWithoutExtension; |
| 1729 Path customHtmlPath = dir.append('$nameNoExt.html'); | 1715 Path customHtmlPath = dir.append('$nameNoExt.html'); |
| 1730 File customHtml = new File(customHtmlPath.toNativePath()); | 1716 File customHtml = new File(customHtmlPath.toNativePath()); |
| 1731 if (!customHtml.existsSync()) { | 1717 if (!customHtml.existsSync()) { |
| 1732 super.enqueueBrowserTest( | 1718 super.enqueueBrowserTest( |
| 1733 baseCommands, packageRoot, packages, info, testName, expectations); | 1719 baseCommands, packageRoot, packages, info, testName, expectations); |
| 1734 } else { | 1720 } else { |
| 1735 Path relativeHtml = customHtmlPath.relativeTo(TestUtils.dartDir); | 1721 Path relativeHtml = customHtmlPath.relativeTo(TestUtils.dartDir); |
| 1736 List<Command> commands = []..addAll(baseCommands); | 1722 var commands = baseCommands.toList(); |
| 1737 var fullPath = _createUrlPathFromFile(customHtmlPath); | 1723 var fullPath = _createUrlPathFromFile(customHtmlPath); |
| 1738 | 1724 |
| 1739 commands.add(CommandBuilder.instance.getBrowserTestCommand( | 1725 commands.add(CommandBuilder.instance.getBrowserTestCommand( |
| 1740 runtime, fullPath, configuration, !isNegative(info))); | 1726 runtime, fullPath, configuration, !isNegative(info))); |
| 1741 String testDisplayName = '$suiteName/$testName'; | 1727 String testDisplayName = '$suiteName/$testName'; |
| 1742 enqueueNewTestCase(new BrowserTestCase( | 1728 enqueueNewTestCase(new BrowserTestCase( |
| 1743 testDisplayName, | 1729 testDisplayName, |
| 1744 commands, | 1730 commands, |
| 1745 configuration, | 1731 configuration, |
| 1746 expectations, | 1732 expectations, |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1848 } | 1834 } |
| 1849 return _cache[path]; | 1835 return _cache[path]; |
| 1850 } | 1836 } |
| 1851 } | 1837 } |
| 1852 | 1838 |
| 1853 class TestUtils { | 1839 class TestUtils { |
| 1854 /** | 1840 /** |
| 1855 * Any script using TestUtils must set dartDirUri to a file:// URI | 1841 * Any script using TestUtils must set dartDirUri to a file:// URI |
| 1856 * pointing to the root of the Dart checkout. | 1842 * pointing to the root of the Dart checkout. |
| 1857 */ | 1843 */ |
| 1858 static setDartDirUri(uri) { | 1844 static void setDartDirUri(Uri uri) { |
| 1859 dartDirUri = uri; | 1845 dartDirUri = uri; |
| 1860 dartDir = new Path(uri.toFilePath()); | 1846 dartDir = new Path(uri.toFilePath()); |
| 1861 } | 1847 } |
| 1862 | 1848 |
| 1863 static Random rand = new Random.secure(); | 1849 static Random rand = new Random.secure(); |
| 1864 static Uri dartDirUri; | 1850 static Uri dartDirUri; |
| 1865 static Path dartDir; | 1851 static Path dartDir; |
| 1866 static LastModifiedCache lastModifiedCache = new LastModifiedCache(); | 1852 static LastModifiedCache lastModifiedCache = new LastModifiedCache(); |
| 1867 static ExistsCache existsCache = new ExistsCache(); | 1853 static ExistsCache existsCache = new ExistsCache(); |
| 1868 static Path currentWorkingDirectory = new Path(Directory.current.path); | 1854 static Path currentWorkingDirectory = new Path(Directory.current.path); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1945 throw new Exception('Can\'t delete path $native_path. ' | 1931 throw new Exception('Can\'t delete path $native_path. ' |
| 1946 'This path might be too long'); | 1932 'This path might be too long'); |
| 1947 } | 1933 } |
| 1948 }); | 1934 }); |
| 1949 } else { | 1935 } else { |
| 1950 var dir = new Directory(path); | 1936 var dir = new Directory(path); |
| 1951 return dir.delete(recursive: true); | 1937 return dir.delete(recursive: true); |
| 1952 } | 1938 } |
| 1953 } | 1939 } |
| 1954 | 1940 |
| 1955 static deleteTempSnapshotDirectory(Map configuration) { | 1941 static void deleteTempSnapshotDirectory(Map configuration) { |
| 1956 if (configuration['compiler'] == 'dart2app' || | 1942 if (configuration['compiler'] == 'dart2app' || |
| 1957 configuration['compiler'] == 'dart2appjit' || | 1943 configuration['compiler'] == 'dart2appjit' || |
| 1958 configuration['compiler'] == 'precompiler') { | 1944 configuration['compiler'] == 'precompiler') { |
| 1959 var checked = configuration['checked'] ? '-checked' : ''; | 1945 var checked = configuration['checked'] ? '-checked' : ''; |
| 1960 var strong = configuration['strong'] ? '-strong' : ''; | 1946 var strong = configuration['strong'] ? '-strong' : ''; |
| 1961 var minified = configuration['minified'] ? '-minified' : ''; | 1947 var minified = configuration['minified'] ? '-minified' : ''; |
| 1962 var csp = configuration['csp'] ? '-csp' : ''; | 1948 var csp = configuration['csp'] ? '-csp' : ''; |
| 1963 var sdk = configuration['use_sdk'] ? '-sdk' : ''; | 1949 var sdk = configuration['use_sdk'] ? '-sdk' : ''; |
| 1964 var dirName = "${configuration['compiler']}" | 1950 var dirName = "${configuration['compiler']}" |
| 1965 "$checked$strong$minified$csp$sdk"; | 1951 "$checked$strong$minified$csp$sdk"; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2084 | 2070 |
| 2085 static String configurationDir(Map configuration) { | 2071 static String configurationDir(Map configuration) { |
| 2086 // This returns the correct configuration directory (the last component | 2072 // This returns the correct configuration directory (the last component |
| 2087 // of the output directory path) for regular dart checkouts. | 2073 // of the output directory path) for regular dart checkouts. |
| 2088 // Dartium checkouts use the --build-directory option to pass in the | 2074 // Dartium checkouts use the --build-directory option to pass in the |
| 2089 // correct build directory explicitly. | 2075 // correct build directory explicitly. |
| 2090 // We allow our code to have been cross compiled, i.e., that there | 2076 // We allow our code to have been cross compiled, i.e., that there |
| 2091 // is an X in front of the arch. We don't allow both a cross compiled | 2077 // is an X in front of the arch. We don't allow both a cross compiled |
| 2092 // and a normal version to be present (except if you specifically pass | 2078 // and a normal version to be present (except if you specifically pass |
| 2093 // in the build_directory). | 2079 // in the build_directory). |
| 2094 var mode; | 2080 String mode; |
| 2095 switch (configuration['mode']) { | 2081 switch (configuration['mode']) { |
| 2096 case 'debug': | 2082 case 'debug': |
| 2097 mode = 'Debug'; | 2083 mode = 'Debug'; |
| 2098 break; | 2084 break; |
| 2099 case 'release': | 2085 case 'release': |
| 2100 mode = 'Release'; | 2086 mode = 'Release'; |
| 2101 break; | 2087 break; |
| 2102 case 'product': | 2088 case 'product': |
| 2103 mode = 'Product'; | 2089 mode = 'Product'; |
| 2104 break; | 2090 break; |
| 2105 default: | 2091 default: |
| 2106 throw 'Unrecognized mode configuration: ${configuration['mode']}'; | 2092 throw 'Unrecognized mode configuration: ${configuration['mode']}'; |
| 2107 } | 2093 } |
| 2108 var os; | 2094 String os; |
| 2109 switch (configuration['system']) { | 2095 switch (configuration['system']) { |
| 2110 case 'android': | 2096 case 'android': |
| 2111 os = 'Android'; | 2097 os = 'Android'; |
| 2112 break; | 2098 break; |
| 2113 case 'fuchsia': | 2099 case 'fuchsia': |
| 2114 case 'linux': | 2100 case 'linux': |
| 2115 case 'macos': | 2101 case 'macos': |
| 2116 case 'windows': | 2102 case 'windows': |
| 2117 os = ''; | 2103 os = ''; |
| 2118 break; | 2104 break; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2229 } | 2215 } |
| 2230 if (path.length > WINDOWS_SHORTEN_PATH_LIMIT) { | 2216 if (path.length > WINDOWS_SHORTEN_PATH_LIMIT) { |
| 2231 ++shortNameCounter; | 2217 ++shortNameCounter; |
| 2232 var pathEnd = path.substring(path.length - WINDOWS_PATH_END_LENGTH); | 2218 var pathEnd = path.substring(path.length - WINDOWS_PATH_END_LENGTH); |
| 2233 path = "short${shortNameCounter}_$pathEnd"; | 2219 path = "short${shortNameCounter}_$pathEnd"; |
| 2234 } | 2220 } |
| 2235 } | 2221 } |
| 2236 return path; | 2222 return path; |
| 2237 } | 2223 } |
| 2238 } | 2224 } |
| OLD | NEW |