Chromium Code Reviews| 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 | 418 |
| 419 /** | 419 /** |
| 420 * Helper function for discovering the packages in the dart repository. | 420 * Helper function for discovering the packages in the dart repository. |
| 421 */ | 421 */ |
| 422 Future<List> listDir(Path path, Function isValid) { | 422 Future<List> listDir(Path path, Function isValid) { |
| 423 var dir = new Directory(path.toNativePath()); | 423 var dir = new Directory(path.toNativePath()); |
| 424 return dir.exists().then((var exist) { | 424 return dir.exists().then((exists) { |
| 425 if (!exist) return []; | 425 if (!exists) return []; |
| 426 return dir | 426 return dir |
| 427 .list(recursive: false) | 427 .list(recursive: false) |
| 428 .where((fse) => fse is Directory) | 428 .where((fse) => fse is Directory) |
| 429 .map((Directory directory) { | 429 .map((FileSystemEntity entity) { |
| 430 var directory = entity as Directory; | |
|
Bill Hesse
2017/05/04 15:49:38
I'm pretty annoyed that this is needed. Oh well.
Bob Nystrom
2017/07/18 18:06:16
Yes. The long term fix is to add a method to Itera
| |
| 430 var fullPath = directory.absolute.path; | 431 var fullPath = directory.absolute.path; |
| 431 var packageName = new Path(fullPath).filename; | 432 var packageName = new Path(fullPath).filename; |
| 432 if (isValid(packageName)) { | 433 if (isValid(packageName)) { |
| 433 return [packageName, path.append(packageName).toNativePath()]; | 434 return [packageName, path.append(packageName).toNativePath()]; |
| 434 } | 435 } |
| 435 return null; | 436 return null; |
| 436 }) | 437 }) |
| 437 .where((name) => name != null) | 438 .where((name) => name != null) |
| 438 .toList(); | 439 .toList(); |
| 439 }); | 440 }); |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 464 class CCTestSuite extends TestSuite { | 465 class CCTestSuite extends TestSuite { |
| 465 final String testPrefix; | 466 final String testPrefix; |
| 466 String targetRunnerPath; | 467 String targetRunnerPath; |
| 467 String hostRunnerPath; | 468 String hostRunnerPath; |
| 468 final String dartDir; | 469 final String dartDir; |
| 469 List<String> statusFilePaths; | 470 List<String> statusFilePaths; |
| 470 | 471 |
| 471 CCTestSuite(Map configuration, String suiteName, String runnerName, | 472 CCTestSuite(Map configuration, String suiteName, String runnerName, |
| 472 this.statusFilePaths, | 473 this.statusFilePaths, |
| 473 {this.testPrefix: ''}) | 474 {this.testPrefix: ''}) |
| 474 : super(configuration, suiteName), | 475 : dartDir = TestUtils.dartDir.toNativePath(), |
| 475 dartDir = TestUtils.dartDir.toNativePath() { | 476 super(configuration, suiteName) { |
| 476 // For running the tests we use the given '$runnerName' binary | 477 // For running the tests we use the given '$runnerName' binary |
| 477 targetRunnerPath = '$buildDir/$runnerName'; | 478 targetRunnerPath = '$buildDir/$runnerName'; |
| 478 | 479 |
| 479 // For listing the tests we use the '$runnerName.host' binary if it exists | 480 // For listing the tests we use the '$runnerName.host' binary if it exists |
| 480 // and use '$runnerName' if it doesn't. | 481 // and use '$runnerName' if it doesn't. |
| 481 var binarySuffix = Platform.operatingSystem == 'windows' ? '.exe' : ''; | 482 var binarySuffix = Platform.operatingSystem == 'windows' ? '.exe' : ''; |
| 482 var hostBinary = '$targetRunnerPath.host$binarySuffix'; | 483 var hostBinary = '$targetRunnerPath.host$binarySuffix'; |
| 483 if (new File(hostBinary).existsSync()) { | 484 if (new File(hostBinary).existsSync()) { |
| 484 hostRunnerPath = hostBinary; | 485 hostRunnerPath = hostBinary; |
| 485 } else { | 486 } else { |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 574 List<TestInformation> cachedTests; | 575 List<TestInformation> cachedTests; |
| 575 final Path dartDir; | 576 final Path dartDir; |
| 576 Predicate<String> isTestFilePredicate; | 577 Predicate<String> isTestFilePredicate; |
| 577 final bool listRecursively; | 578 final bool listRecursively; |
| 578 final extraVmOptions; | 579 final extraVmOptions; |
| 579 List<Uri> _dart2JsBootstrapDependencies; | 580 List<Uri> _dart2JsBootstrapDependencies; |
| 580 | 581 |
| 581 StandardTestSuite(Map configuration, String suiteName, Path suiteDirectory, | 582 StandardTestSuite(Map configuration, String suiteName, Path suiteDirectory, |
| 582 this.statusFilePaths, | 583 this.statusFilePaths, |
| 583 {this.isTestFilePredicate, bool recursive: false}) | 584 {this.isTestFilePredicate, bool recursive: false}) |
| 584 : super(configuration, suiteName), | 585 : dartDir = TestUtils.dartDir, |
| 585 dartDir = TestUtils.dartDir, | |
| 586 listRecursively = recursive, | 586 listRecursively = recursive, |
| 587 suiteDir = TestUtils.dartDir.join(suiteDirectory), | 587 suiteDir = TestUtils.dartDir.join(suiteDirectory), |
| 588 extraVmOptions = TestUtils.getExtraVmOptions(configuration) { | 588 extraVmOptions = TestUtils.getExtraVmOptions(configuration), |
| 589 super(configuration, suiteName) { | |
| 589 if (!useSdk) { | 590 if (!useSdk) { |
| 590 _dart2JsBootstrapDependencies = []; | 591 _dart2JsBootstrapDependencies = []; |
| 591 } else { | 592 } else { |
| 592 var snapshotPath = TestUtils | 593 var snapshotPath = TestUtils |
| 593 .absolutePath( | 594 .absolutePath( |
| 594 new Path(buildDir).join(new Path('dart-sdk/bin/snapshots/' | 595 new Path(buildDir).join(new Path('dart-sdk/bin/snapshots/' |
| 595 'utils_wrapper.dart.snapshot'))) | 596 'utils_wrapper.dart.snapshot'))) |
| 596 .toString(); | 597 .toString(); |
| 597 _dart2JsBootstrapDependencies = [ | 598 _dart2JsBootstrapDependencies = [ |
| 598 new Uri(scheme: 'file', path: snapshotPath) | 599 new Uri(scheme: 'file', path: snapshotPath) |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 enqueueDirectory(dir, group); | 721 enqueueDirectory(dir, group); |
| 721 return group.future; | 722 return group.future; |
| 722 } | 723 } |
| 723 }); | 724 }); |
| 724 } | 725 } |
| 725 | 726 |
| 726 void enqueueDirectory(Directory dir, FutureGroup group) { | 727 void enqueueDirectory(Directory dir, FutureGroup group) { |
| 727 var lister = dir | 728 var lister = dir |
| 728 .list(recursive: listRecursively) | 729 .list(recursive: listRecursively) |
| 729 .where((fse) => fse is File) | 730 .where((fse) => fse is File) |
| 730 .forEach((File f) { | 731 .forEach((FileSystemEntity entity) { |
| 731 enqueueFile(f.path, group); | 732 enqueueFile((entity as File).path, group); |
| 732 }); | 733 }); |
| 733 group.add(lister); | 734 group.add(lister); |
| 734 } | 735 } |
| 735 | 736 |
| 736 void enqueueFile(String filename, FutureGroup group) { | 737 void enqueueFile(String filename, FutureGroup group) { |
| 737 if (isHtmlTestFile(filename)) { | 738 if (isHtmlTestFile(filename)) { |
| 738 var info = htmlTest.getInformation(filename); | 739 var info = htmlTest.getInformation(filename); |
| 739 if (info == null) { | 740 if (info == null) { |
| 740 DebugLogger | 741 DebugLogger |
| 741 .error("HtmlTest $filename does not contain required annotations"); | 742 .error("HtmlTest $filename does not contain required annotations"); |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 851 | 852 |
| 852 for (var vmOptionsVarient = 0; | 853 for (var vmOptionsVarient = 0; |
| 853 vmOptionsVarient < vmOptionsList.length; | 854 vmOptionsVarient < vmOptionsList.length; |
| 854 vmOptionsVarient++) { | 855 vmOptionsVarient++) { |
| 855 var vmOptions = vmOptionsList[vmOptionsVarient]; | 856 var vmOptions = vmOptionsList[vmOptionsVarient]; |
| 856 var allVmOptions = vmOptions; | 857 var allVmOptions = vmOptions; |
| 857 if (!extraVmOptions.isEmpty) { | 858 if (!extraVmOptions.isEmpty) { |
| 858 allVmOptions = new List.from(vmOptions)..addAll(extraVmOptions); | 859 allVmOptions = new List.from(vmOptions)..addAll(extraVmOptions); |
| 859 } | 860 } |
| 860 | 861 |
| 861 var commands = []..addAll(baseCommands); | 862 var commands = baseCommands.toList(); |
| 862 commands.addAll( | 863 commands.addAll( |
| 863 makeCommands(info, vmOptionsVarient, allVmOptions, commonArguments)); | 864 makeCommands(info, vmOptionsVarient, allVmOptions, commonArguments)); |
| 864 enqueueNewTestCase(new TestCase( | 865 enqueueNewTestCase(new TestCase( |
| 865 '$suiteName/$testName', commands, configuration, expectations, | 866 '$suiteName/$testName', commands, configuration, expectations, |
| 866 isNegative: isNegative(info), info: info)); | 867 isNegative: isNegative(info), info: info)); |
| 867 } | 868 } |
| 868 } | 869 } |
| 869 | 870 |
| 870 bool expectCompileError(TestInformation info) { | 871 bool expectCompileError(TestInformation info) { |
| 871 return info.hasCompileError || | 872 return info.hasCompileError || |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1000 | 1001 |
| 1001 Uri _getUriForBrowserTest(String pathComponent, String subtestName) { | 1002 Uri _getUriForBrowserTest(String pathComponent, String subtestName) { |
| 1002 // Note: If we run test.py with the "--list" option, no http servers | 1003 // Note: If we run test.py with the "--list" option, no http servers |
| 1003 // will be started. So we return a dummy url instead. | 1004 // will be started. So we return a dummy url instead. |
| 1004 if (configuration['list']) { | 1005 if (configuration['list']) { |
| 1005 return Uri.parse('http://listing_the_tests_only'); | 1006 return Uri.parse('http://listing_the_tests_only'); |
| 1006 } | 1007 } |
| 1007 assert(configuration.containsKey('_servers_')); | 1008 assert(configuration.containsKey('_servers_')); |
| 1008 int serverPort = configuration['_servers_'].port; | 1009 int serverPort = configuration['_servers_'].port; |
| 1009 int crossOriginPort = configuration['_servers_'].crossOriginPort; | 1010 int crossOriginPort = configuration['_servers_'].crossOriginPort; |
| 1010 Map parameters = {'crossOriginPort': crossOriginPort.toString()}; | 1011 var parameters = {'crossOriginPort': crossOriginPort.toString()}; |
| 1011 if (subtestName != null) { | 1012 if (subtestName != null) { |
| 1012 parameters['group'] = subtestName; | 1013 parameters['group'] = subtestName; |
| 1013 } | 1014 } |
| 1014 return new Uri( | 1015 return new Uri( |
| 1015 scheme: 'http', | 1016 scheme: 'http', |
| 1016 host: configuration['local_ip'], | 1017 host: configuration['local_ip'], |
| 1017 port: serverPort, | 1018 port: serverPort, |
| 1018 path: pathComponent, | 1019 path: pathComponent, |
| 1019 queryParameters: parameters); | 1020 queryParameters: parameters); |
| 1020 } | 1021 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1190 multitest ? info.optionsFromFile['subtestNames'] : [null]; | 1191 multitest ? info.optionsFromFile['subtestNames'] : [null]; |
| 1191 for (String subtestName in subtestNames) { | 1192 for (String subtestName in subtestNames) { |
| 1192 // Construct the command that executes the browser test | 1193 // Construct the command that executes the browser test |
| 1193 List<Command> commandSet = new List<Command>.from(commands); | 1194 List<Command> commandSet = new List<Command>.from(commands); |
| 1194 | 1195 |
| 1195 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath)); | 1196 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath)); |
| 1196 var fullHtmlPath = | 1197 var fullHtmlPath = |
| 1197 _getUriForBrowserTest(htmlPath_subtest, subtestName).toString(); | 1198 _getUriForBrowserTest(htmlPath_subtest, subtestName).toString(); |
| 1198 | 1199 |
| 1199 if (runtime == "drt") { | 1200 if (runtime == "drt") { |
| 1200 var dartFlags = []; | 1201 var dartFlags = <String>[]; |
| 1201 var contentShellOptions = []; | 1202 var contentShellOptions = ['--no-timeout', '--run-layout-test']; |
| 1202 | |
| 1203 contentShellOptions.add('--no-timeout'); | |
| 1204 contentShellOptions.add('--run-layout-test'); | |
| 1205 | 1203 |
| 1206 // Disable the GPU under Linux and Dartium. If the GPU is enabled, | 1204 // Disable the GPU under Linux and Dartium. If the GPU is enabled, |
| 1207 // Chrome may send a termination signal to a test. The test will be | 1205 // Chrome may send a termination signal to a test. The test will be |
| 1208 // terminated if a machine (bot) doesn't have a GPU or if a test is | 1206 // terminated if a machine (bot) doesn't have a GPU or if a test is |
| 1209 // still running after a certain period of time. | 1207 // still running after a certain period of time. |
| 1210 if (configuration['system'] == 'linux' && | 1208 if (configuration['system'] == 'linux' && |
| 1211 configuration['runtime'] == 'drt') { | 1209 configuration['runtime'] == 'drt') { |
| 1212 contentShellOptions.add('--disable-gpu'); | 1210 contentShellOptions.add('--disable-gpu'); |
| 1213 } | 1211 } |
| 1214 if (compiler == 'none') { | 1212 if (compiler == 'none') { |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1388 } | 1386 } |
| 1389 if (Platform.operatingSystem == 'macos') { | 1387 if (Platform.operatingSystem == 'macos') { |
| 1390 final path = dartDir.append( | 1388 final path = dartDir.append( |
| 1391 '/client/tests/drt/Content Shell.app/Contents/MacOS/Content Shell'); | 1389 '/client/tests/drt/Content Shell.app/Contents/MacOS/Content Shell'); |
| 1392 return path.toNativePath(); | 1390 return path.toNativePath(); |
| 1393 } | 1391 } |
| 1394 return dartDir.append('client/tests/drt/content_shell').toNativePath(); | 1392 return dartDir.append('client/tests/drt/content_shell').toNativePath(); |
| 1395 } | 1393 } |
| 1396 | 1394 |
| 1397 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) { | 1395 List<String> commonArgumentsFromFile(Path filePath, Map optionsFromFile) { |
| 1398 List args = TestUtils.standardOptions(configuration); | 1396 var args = TestUtils.standardOptions(configuration); |
| 1399 | 1397 |
| 1400 String packages = packagesArgument( | 1398 String packages = packagesArgument( |
| 1401 optionsFromFile['packageRoot'], optionsFromFile['packages']); | 1399 optionsFromFile['packageRoot'], optionsFromFile['packages']); |
| 1402 if (packages != null) { | 1400 if (packages != null) { |
| 1403 args.add(packages); | 1401 args.add(packages); |
| 1404 } | 1402 } |
| 1405 args.addAll(additionalOptions(filePath)); | 1403 args.addAll(additionalOptions(filePath)); |
| 1406 if (configuration['analyzer']) { | 1404 if (configuration['analyzer']) { |
| 1407 args.add('--format=machine'); | 1405 args.add('--format=machine'); |
| 1408 args.add('--no-hints'); | 1406 args.add('--no-hints'); |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2005 result = 'out/'; | 2003 result = 'out/'; |
| 2006 } else if (system == 'macos') { | 2004 } else if (system == 'macos') { |
| 2007 result = 'xcodebuild/'; | 2005 result = 'xcodebuild/'; |
| 2008 } else { | 2006 } else { |
| 2009 throw new Exception('Unknown operating system: "$system"'); | 2007 throw new Exception('Unknown operating system: "$system"'); |
| 2010 } | 2008 } |
| 2011 return result; | 2009 return result; |
| 2012 } | 2010 } |
| 2013 | 2011 |
| 2014 static List<String> standardOptions(Map configuration) { | 2012 static List<String> standardOptions(Map configuration) { |
| 2015 List args = ["--ignore-unrecognized-flags"]; | 2013 var args = ["--ignore-unrecognized-flags"]; |
| 2016 String compiler = configuration["compiler"]; | 2014 String compiler = configuration["compiler"]; |
| 2017 if (compiler == "dart2js") { | 2015 if (compiler == "dart2js") { |
| 2018 args = ['--generate-code-with-compile-time-errors', '--test-mode']; | 2016 args = ['--generate-code-with-compile-time-errors', '--test-mode']; |
| 2019 if (configuration["checked"]) { | 2017 if (configuration["checked"]) { |
| 2020 args.add('--enable-checked-mode'); | 2018 args.add('--enable-checked-mode'); |
| 2021 } | 2019 } |
| 2022 // args.add("--verbose"); | 2020 // args.add("--verbose"); |
| 2023 if (!isBrowserRuntime(configuration['runtime'])) { | 2021 if (!isBrowserRuntime(configuration['runtime'])) { |
| 2024 args.add("--allow-mock-compilation"); | 2022 args.add("--allow-mock-compilation"); |
| 2025 args.add("--categories=all"); | 2023 args.add("--categories=all"); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2229 } | 2227 } |
| 2230 if (path.length > WINDOWS_SHORTEN_PATH_LIMIT) { | 2228 if (path.length > WINDOWS_SHORTEN_PATH_LIMIT) { |
| 2231 ++shortNameCounter; | 2229 ++shortNameCounter; |
| 2232 var pathEnd = path.substring(path.length - WINDOWS_PATH_END_LENGTH); | 2230 var pathEnd = path.substring(path.length - WINDOWS_PATH_END_LENGTH); |
| 2233 path = "short${shortNameCounter}_$pathEnd"; | 2231 path = "short${shortNameCounter}_$pathEnd"; |
| 2234 } | 2232 } |
| 2235 } | 2233 } |
| 2236 return path; | 2234 return path; |
| 2237 } | 2235 } |
| 2238 } | 2236 } |
| OLD | NEW |