| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 ? '$buildDir/dart-sdk/bin/dart$suffix' | 198 ? '$buildDir/dart-sdk/bin/dart$suffix' |
| 199 : '$buildDir/dart$suffix'; | 199 : '$buildDir/dart$suffix'; |
| 200 } | 200 } |
| 201 | 201 |
| 202 TestUtils.ensureExists(dartExecutable, configuration); | 202 TestUtils.ensureExists(dartExecutable, configuration); |
| 203 return dartExecutable; | 203 return dartExecutable; |
| 204 } | 204 } |
| 205 | 205 |
| 206 String get d8FileName { | 206 String get d8FileName { |
| 207 var suffix = getExecutableSuffix('d8'); | 207 var suffix = getExecutableSuffix('d8'); |
| 208 var d8Dir = TestUtils.dartDir().append('third_party/d8'); | 208 var d8Dir = TestUtils.dartDir.append('third_party/d8'); |
| 209 var d8Path = d8Dir.append('${Platform.operatingSystem}/d8$suffix'); | 209 var d8Path = d8Dir.append('${Platform.operatingSystem}/d8$suffix'); |
| 210 var d8 = d8Path.toNativePath(); | 210 var d8 = d8Path.toNativePath(); |
| 211 TestUtils.ensureExists(d8, configuration); | 211 TestUtils.ensureExists(d8, configuration); |
| 212 return d8; | 212 return d8; |
| 213 } | 213 } |
| 214 | 214 |
| 215 String get jsShellFileName { | 215 String get jsShellFileName { |
| 216 var executableSuffix = getExecutableSuffix('jsshell'); | 216 var executableSuffix = getExecutableSuffix('jsshell'); |
| 217 var executable = 'jsshell$executableSuffix'; | 217 var executable = 'jsshell$executableSuffix'; |
| 218 var jsshellDir = '${TestUtils.dartDir()}/tools/testing/bin'; | 218 var jsshellDir = '${TestUtils.dartDir}/tools/testing/bin'; |
| 219 return '$jsshellDir/$executable'; | 219 return '$jsshellDir/$executable'; |
| 220 } | 220 } |
| 221 | 221 |
| 222 /** | 222 /** |
| 223 * The file extension (if any) that should be added to the given executable | 223 * The file extension (if any) that should be added to the given executable |
| 224 * name for the current platform. | 224 * name for the current platform. |
| 225 */ | 225 */ |
| 226 // TODO(ahe): Get rid of this. Use executableBinarySuffix instead. | 226 // TODO(ahe): Get rid of this. Use executableBinarySuffix instead. |
| 227 String getExecutableSuffix(String executable) { | 227 String getExecutableSuffix(String executable) { |
| 228 if (Platform.operatingSystem == 'windows') { | 228 if (Platform.operatingSystem == 'windows') { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 256 // and will enqueue the test (if necessary). | 256 // and will enqueue the test (if necessary). |
| 257 void enqueueNewTestCase(TestCase testCase) { | 257 void enqueueNewTestCase(TestCase testCase) { |
| 258 var expectations = testCase.expectedOutcomes; | 258 var expectations = testCase.expectedOutcomes; |
| 259 | 259 |
| 260 // Handle sharding based on the original test path (i.e. all multitests | 260 // Handle sharding based on the original test path (i.e. all multitests |
| 261 // of a given original test belong to the same shard) | 261 // of a given original test belong to the same shard) |
| 262 int shards = configuration['shards']; | 262 int shards = configuration['shards']; |
| 263 if (shards > 1) { | 263 if (shards > 1) { |
| 264 int shard = configuration['shard']; | 264 int shard = configuration['shard']; |
| 265 var testPath = | 265 var testPath = |
| 266 testCase.info.originTestPath.relativeTo(TestUtils.dartDir()); | 266 testCase.info.originTestPath.relativeTo(TestUtils.dartDir); |
| 267 if ("$testPath".hashCode % shards != shard - 1) { | 267 if ("$testPath".hashCode % shards != shard - 1) { |
| 268 return; | 268 return; |
| 269 } | 269 } |
| 270 } | 270 } |
| 271 // Test if the selector includes this test. | 271 // Test if the selector includes this test. |
| 272 RegExp pattern = configuration['selectors'][suiteName]; | 272 RegExp pattern = configuration['selectors'][suiteName]; |
| 273 if (!pattern.hasMatch(testCase.displayName)) { | 273 if (!pattern.hasMatch(testCase.displayName)) { |
| 274 return; | 274 return; |
| 275 } | 275 } |
| 276 | 276 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 290 if (expectations.contains(Expectation.SKIP) || | 290 if (expectations.contains(Expectation.SKIP) || |
| 291 expectations.contains(Expectation.SKIP_BY_DESIGN)) { | 291 expectations.contains(Expectation.SKIP_BY_DESIGN)) { |
| 292 return; | 292 return; |
| 293 } | 293 } |
| 294 | 294 |
| 295 doTest(testCase); | 295 doTest(testCase); |
| 296 } | 296 } |
| 297 | 297 |
| 298 String createGeneratedTestDirectoryHelper( | 298 String createGeneratedTestDirectoryHelper( |
| 299 String name, String dirname, Path testPath, String optionsName) { | 299 String name, String dirname, Path testPath, String optionsName) { |
| 300 Path relative = testPath.relativeTo(TestUtils.dartDir()); | 300 Path relative = testPath.relativeTo(TestUtils.dartDir); |
| 301 relative = relative.directoryPath.append(relative.filenameWithoutExtension); | 301 relative = relative.directoryPath.append(relative.filenameWithoutExtension); |
| 302 String testUniqueName = TestUtils.getShortName(relative.toString()); | 302 String testUniqueName = TestUtils.getShortName(relative.toString()); |
| 303 if (!optionsName.isEmpty) { | 303 if (!optionsName.isEmpty) { |
| 304 testUniqueName = '$testUniqueName-$optionsName'; | 304 testUniqueName = '$testUniqueName-$optionsName'; |
| 305 } | 305 } |
| 306 | 306 |
| 307 Path generatedTestPath = new Path(buildDir) | 307 Path generatedTestPath = new Path(buildDir) |
| 308 .append('generated_$name') | 308 .append('generated_$name') |
| 309 .append(dirname) | 309 .append(dirname) |
| 310 .append(testUniqueName); | 310 .append(testUniqueName); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 var sdk = configuration['use_sdk'] ? '-sdk' : ''; | 357 var sdk = configuration['use_sdk'] ? '-sdk' : ''; |
| 358 var packages = configuration['use_public_packages'] | 358 var packages = configuration['use_public_packages'] |
| 359 ? '-public_packages' : ''; | 359 ? '-public_packages' : ''; |
| 360 var dirName = "${configuration['compiler']}" | 360 var dirName = "${configuration['compiler']}" |
| 361 "$checked$minified$csp$packages$sdk"; | 361 "$checked$minified$csp$packages$sdk"; |
| 362 return createGeneratedTestDirectoryHelper( | 362 return createGeneratedTestDirectoryHelper( |
| 363 "compilations", dirName, testPath, ""); | 363 "compilations", dirName, testPath, ""); |
| 364 } | 364 } |
| 365 | 365 |
| 366 String createPubspecCheckoutDirectory(Path directoryOfPubspecYaml) { | 366 String createPubspecCheckoutDirectory(Path directoryOfPubspecYaml) { |
| 367 var relativeDir = directoryOfPubspecYaml.relativeTo(TestUtils.dartDir()); | 367 var relativeDir = directoryOfPubspecYaml.relativeTo(TestUtils.dartDir); |
| 368 var sdk = configuration['use_sdk'] ? '-sdk' : ''; | 368 var sdk = configuration['use_sdk'] ? '-sdk' : ''; |
| 369 var pkg = configuration['use_public_packages'] | 369 var pkg = configuration['use_public_packages'] |
| 370 ? 'public_packages' : 'repo_packages'; | 370 ? 'public_packages' : 'repo_packages'; |
| 371 return createGeneratedTestDirectoryHelper( | 371 return createGeneratedTestDirectoryHelper( |
| 372 "pubspec_checkouts", '$pkg$sdk', directoryOfPubspecYaml, ""); | 372 "pubspec_checkouts", '$pkg$sdk', directoryOfPubspecYaml, ""); |
| 373 } | 373 } |
| 374 | 374 |
| 375 String createPubPackageBuildsDirectory(Path directoryOfPubspecYaml) { | 375 String createPubPackageBuildsDirectory(Path directoryOfPubspecYaml) { |
| 376 var relativeDir = directoryOfPubspecYaml.relativeTo(TestUtils.dartDir()); | 376 var relativeDir = directoryOfPubspecYaml.relativeTo(TestUtils.dartDir); |
| 377 var pkg = configuration['use_public_packages'] | 377 var pkg = configuration['use_public_packages'] |
| 378 ? 'public_packages' : 'repo_packages'; | 378 ? 'public_packages' : 'repo_packages'; |
| 379 return createGeneratedTestDirectoryHelper( | 379 return createGeneratedTestDirectoryHelper( |
| 380 "pub_package_builds", pkg, directoryOfPubspecYaml, ""); | 380 "pub_package_builds", pkg, directoryOfPubspecYaml, ""); |
| 381 } | 381 } |
| 382 | 382 |
| 383 /** | 383 /** |
| 384 * Helper function for discovering the packages in the dart repository. | 384 * Helper function for discovering the packages in the dart repository. |
| 385 */ | 385 */ |
| 386 Future<List> listDir(Path path, Function isValid) { | 386 Future<List> listDir(Path path, Function isValid) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 403 /* | 403 /* |
| 404 * Layout of packages inside the dart repository: | 404 * Layout of packages inside the dart repository: |
| 405 * dart/ | 405 * dart/ |
| 406 * pkg/PACKAGE_NAME | 406 * pkg/PACKAGE_NAME |
| 407 * pkg/third_party/PACKAGE_NAME | 407 * pkg/third_party/PACKAGE_NAME |
| 408 * third_party/pkg/PACKAGE_NAME | 408 * third_party/pkg/PACKAGE_NAME |
| 409 */ | 409 */ |
| 410 | 410 |
| 411 isValid(packageName) => packageName != 'third_party'; | 411 isValid(packageName) => packageName != 'third_party'; |
| 412 | 412 |
| 413 var dartDir = TestUtils.dartDir(); | 413 var dartDir = TestUtils.dartDir; |
| 414 var futures = [ | 414 var futures = [ |
| 415 listDir(dartDir.append('pkg'), isValid), | 415 listDir(dartDir.append('pkg'), isValid), |
| 416 listDir(dartDir.append('pkg').append('third_party'), isValid), | 416 listDir(dartDir.append('pkg').append('third_party'), isValid), |
| 417 listDir(dartDir.append('third_party').append('pkg'), isValid), | 417 listDir(dartDir.append('third_party').append('pkg'), isValid), |
| 418 ]; | 418 ]; |
| 419 return Future.wait(futures).then((results) { | 419 return Future.wait(futures).then((results) { |
| 420 var packageDirectories = {}; | 420 var packageDirectories = {}; |
| 421 for (var result in results) { | 421 for (var result in results) { |
| 422 for (var packageTuple in result) { | 422 for (var packageTuple in result) { |
| 423 String packageName = packageTuple[0]; | 423 String packageName = packageTuple[0]; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 436 Future<Map> discoverSamplesInRepository() { | 436 Future<Map> discoverSamplesInRepository() { |
| 437 /* | 437 /* |
| 438 * Layout of samples inside the dart repository: | 438 * Layout of samples inside the dart repository: |
| 439 * dart/ | 439 * dart/ |
| 440 * samples/SAMPLE_NAME | 440 * samples/SAMPLE_NAME |
| 441 * samples/third_party/SAMPLE_NAME | 441 * samples/third_party/SAMPLE_NAME |
| 442 */ | 442 */ |
| 443 | 443 |
| 444 isValid(packageName) => packageName != 'third_party'; | 444 isValid(packageName) => packageName != 'third_party'; |
| 445 | 445 |
| 446 var dartDir = TestUtils.dartDir(); | 446 var dartDir = TestUtils.dartDir; |
| 447 var futures = [ | 447 var futures = [ |
| 448 listDir(dartDir.append('samples'), isValid), | 448 listDir(dartDir.append('samples'), isValid), |
| 449 listDir(dartDir.append('samples').append('third_party'), isValid), | 449 listDir(dartDir.append('samples').append('third_party'), isValid), |
| 450 ]; | 450 ]; |
| 451 return Future.wait(futures).then((results) { | 451 return Future.wait(futures).then((results) { |
| 452 var packageDirectories = {}; | 452 var packageDirectories = {}; |
| 453 for (var result in results) { | 453 for (var result in results) { |
| 454 for (var packageTuple in result) { | 454 for (var packageTuple in result) { |
| 455 String packageName = packageTuple[0]; | 455 String packageName = packageTuple[0]; |
| 456 String fullPath = packageTuple[1]; | 456 String fullPath = packageTuple[1]; |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 final String dartDir; | 504 final String dartDir; |
| 505 List<String> statusFilePaths; | 505 List<String> statusFilePaths; |
| 506 VoidFunction doDone; | 506 VoidFunction doDone; |
| 507 | 507 |
| 508 CCTestSuite(Map configuration, | 508 CCTestSuite(Map configuration, |
| 509 String suiteName, | 509 String suiteName, |
| 510 String runnerName, | 510 String runnerName, |
| 511 this.statusFilePaths, | 511 this.statusFilePaths, |
| 512 {this.testPrefix: ''}) | 512 {this.testPrefix: ''}) |
| 513 : super(configuration, suiteName), | 513 : super(configuration, suiteName), |
| 514 dartDir = TestUtils.dartDir().toNativePath() { | 514 dartDir = TestUtils.dartDir.toNativePath() { |
| 515 // For running the tests we use the given '$runnerName' binary | 515 // For running the tests we use the given '$runnerName' binary |
| 516 targetRunnerPath = '$buildDir/$runnerName'; | 516 targetRunnerPath = '$buildDir/$runnerName'; |
| 517 | 517 |
| 518 // For listing the tests we use the '$runnerName.host' binary if it exists | 518 // For listing the tests we use the '$runnerName.host' binary if it exists |
| 519 // and use '$runnerName' if it doesn't. | 519 // and use '$runnerName' if it doesn't. |
| 520 var binarySuffix = Platform.operatingSystem == 'windows' ? '.exe' : ''; | 520 var binarySuffix = Platform.operatingSystem == 'windows' ? '.exe' : ''; |
| 521 var hostBinary = '$targetRunnerPath.host$binarySuffix'; | 521 var hostBinary = '$targetRunnerPath.host$binarySuffix'; |
| 522 if (new File(hostBinary).existsSync()) { | 522 if (new File(hostBinary).existsSync()) { |
| 523 hostRunnerPath = hostBinary; | 523 hostRunnerPath = hostBinary; |
| 524 } else { | 524 } else { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 final bool listRecursively; | 599 final bool listRecursively; |
| 600 final extraVmOptions; | 600 final extraVmOptions; |
| 601 | 601 |
| 602 StandardTestSuite(Map configuration, | 602 StandardTestSuite(Map configuration, |
| 603 String suiteName, | 603 String suiteName, |
| 604 Path suiteDirectory, | 604 Path suiteDirectory, |
| 605 this.statusFilePaths, | 605 this.statusFilePaths, |
| 606 {this.isTestFilePredicate, | 606 {this.isTestFilePredicate, |
| 607 bool recursive: false}) | 607 bool recursive: false}) |
| 608 : super(configuration, suiteName), | 608 : super(configuration, suiteName), |
| 609 dartDir = TestUtils.dartDir(), | 609 dartDir = TestUtils.dartDir, |
| 610 listRecursively = recursive, | 610 listRecursively = recursive, |
| 611 suiteDir = TestUtils.dartDir().join(suiteDirectory), | 611 suiteDir = TestUtils.dartDir.join(suiteDirectory), |
| 612 extraVmOptions = TestUtils.getExtraVmOptions(configuration); | 612 extraVmOptions = TestUtils.getExtraVmOptions(configuration); |
| 613 | 613 |
| 614 /** | 614 /** |
| 615 * Creates a test suite whose file organization matches an expected structure. | 615 * Creates a test suite whose file organization matches an expected structure. |
| 616 * To use this, your suite should look like: | 616 * To use this, your suite should look like: |
| 617 * | 617 * |
| 618 * dart/ | 618 * dart/ |
| 619 * path/ | 619 * path/ |
| 620 * to/ | 620 * to/ |
| 621 * mytestsuite/ | 621 * mytestsuite/ |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 787 createTestCase(filePath, | 787 createTestCase(filePath, |
| 788 optionsFromFile['hasCompileError'], | 788 optionsFromFile['hasCompileError'], |
| 789 optionsFromFile['hasRuntimeError'], | 789 optionsFromFile['hasRuntimeError'], |
| 790 hasStaticWarning: optionsFromFile['hasStaticWarning']); | 790 hasStaticWarning: optionsFromFile['hasStaticWarning']); |
| 791 } | 791 } |
| 792 } | 792 } |
| 793 | 793 |
| 794 static Path _findPubspecYamlFile(Path filePath) { | 794 static Path _findPubspecYamlFile(Path filePath) { |
| 795 final existsCache = TestUtils.existsCache; | 795 final existsCache = TestUtils.existsCache; |
| 796 | 796 |
| 797 Path root = TestUtils.dartDir(); | 797 Path root = TestUtils.dartDir; |
| 798 assert ("$filePath".startsWith("$root")); | 798 assert ("$filePath".startsWith("$root")); |
| 799 | 799 |
| 800 // We start with the parent directory of [filePath] and go up until | 800 // We start with the parent directory of [filePath] and go up until |
| 801 // the root directory (excluding the root). | 801 // the root directory (excluding the root). |
| 802 List<String> segments = | 802 List<String> segments = |
| 803 filePath.directoryPath.relativeTo(root).segments(); | 803 filePath.directoryPath.relativeTo(root).segments(); |
| 804 while (segments.length > 0) { | 804 while (segments.length > 0) { |
| 805 var pubspecYamlPath = | 805 var pubspecYamlPath = |
| 806 new Path(segments.join('/')).append('pubspec.yaml'); | 806 new Path(segments.join('/')).append('pubspec.yaml'); |
| 807 if (existsCache.doesFileExist(pubspecYamlPath.toNativePath())) { | 807 if (existsCache.doesFileExist(pubspecYamlPath.toNativePath())) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 835 | 835 |
| 836 // NOTE: We make a link in the package-root to [packageName], since | 836 // NOTE: We make a link in the package-root to [packageName], since |
| 837 // 'pub get' doesn't create the link to the package containing | 837 // 'pub get' doesn't create the link to the package containing |
| 838 // pubspec.yaml if there is no lib directory. | 838 // pubspec.yaml if there is no lib directory. |
| 839 var packageLink = newPackageRoot.append(packageName); | 839 var packageLink = newPackageRoot.append(packageName); |
| 840 var packageLinkTarget = packageDir.append('lib'); | 840 var packageLinkTarget = packageDir.append('lib'); |
| 841 | 841 |
| 842 // NOTE: We make a link in the package-root to pkg/expect, since | 842 // NOTE: We make a link in the package-root to pkg/expect, since |
| 843 // 'package:expect' is not available on pub.dartlang.org! | 843 // 'package:expect' is not available on pub.dartlang.org! |
| 844 var expectLink = newPackageRoot.append('expect'); | 844 var expectLink = newPackageRoot.append('expect'); |
| 845 var expectLinkTarget = TestUtils.dartDir() | 845 var expectLinkTarget = TestUtils.dartDir |
| 846 .append('pkg').append('expect').append('lib'); | 846 .append('pkg').append('expect').append('lib'); |
| 847 | 847 |
| 848 // Generate dependency overrides if we use repository packages. | 848 // Generate dependency overrides if we use repository packages. |
| 849 var packageDirectories = {}; | 849 var packageDirectories = {}; |
| 850 if (configuration['use_repository_packages']) { | 850 if (configuration['use_repository_packages']) { |
| 851 packageDirectories = new Map.from(localPackageDirectories); | 851 packageDirectories = new Map.from(localPackageDirectories); |
| 852 // Do not create an dependency override for the package itself. | 852 // Do not create an dependency override for the package itself. |
| 853 if (packageDirectories.containsKey(packageName)) { | 853 if (packageDirectories.containsKey(packageName)) { |
| 854 packageDirectories.remove(packageName); | 854 packageDirectories.remove(packageName); |
| 855 } | 855 } |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1047 * the relative path to either the dart or the build directory. | 1047 * the relative path to either the dart or the build directory. |
| 1048 * Thus, the returned [String] will be the path component of the URL | 1048 * Thus, the returned [String] will be the path component of the URL |
| 1049 * corresponding to [file] (the http server serves files relative to the | 1049 * corresponding to [file] (the http server serves files relative to the |
| 1050 * dart/build directories). | 1050 * dart/build directories). |
| 1051 */ | 1051 */ |
| 1052 String _createUrlPathFromFile(Path file) { | 1052 String _createUrlPathFromFile(Path file) { |
| 1053 file = TestUtils.absolutePath(file); | 1053 file = TestUtils.absolutePath(file); |
| 1054 | 1054 |
| 1055 var relativeBuildDir = new Path(TestUtils.buildDir(configuration)); | 1055 var relativeBuildDir = new Path(TestUtils.buildDir(configuration)); |
| 1056 var buildDir = TestUtils.absolutePath(relativeBuildDir); | 1056 var buildDir = TestUtils.absolutePath(relativeBuildDir); |
| 1057 var dartDir = TestUtils.absolutePath(TestUtils.dartDir()); | 1057 var dartDir = TestUtils.absolutePath(TestUtils.dartDir); |
| 1058 | 1058 |
| 1059 var fileString = file.toString(); | 1059 var fileString = file.toString(); |
| 1060 if (fileString.startsWith(buildDir.toString())) { | 1060 if (fileString.startsWith(buildDir.toString())) { |
| 1061 var fileRelativeToBuildDir = file.relativeTo(buildDir); | 1061 var fileRelativeToBuildDir = file.relativeTo(buildDir); |
| 1062 return "/$PREFIX_BUILDDIR/$fileRelativeToBuildDir"; | 1062 return "/$PREFIX_BUILDDIR/$fileRelativeToBuildDir"; |
| 1063 } else if (fileString.startsWith(dartDir.toString())) { | 1063 } else if (fileString.startsWith(dartDir.toString())) { |
| 1064 var fileRelativeToDartDir = file.relativeTo(dartDir); | 1064 var fileRelativeToDartDir = file.relativeTo(dartDir); |
| 1065 return "/$PREFIX_DARTDIR/$fileRelativeToDartDir"; | 1065 return "/$PREFIX_DARTDIR/$fileRelativeToDartDir"; |
| 1066 } | 1066 } |
| 1067 // Unreachable | 1067 // Unreachable |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1742 TestExpectations testExpectations) { | 1742 TestExpectations testExpectations) { |
| 1743 enqueueTestCase(String packageName, String directory) { | 1743 enqueueTestCase(String packageName, String directory) { |
| 1744 var absoluteDirectoryPath = new Path(directory); | 1744 var absoluteDirectoryPath = new Path(directory); |
| 1745 | 1745 |
| 1746 // Early return if this package is not using pub. | 1746 // Early return if this package is not using pub. |
| 1747 if (!fileExists(absoluteDirectoryPath.append('pubspec.yaml'))) { | 1747 if (!fileExists(absoluteDirectoryPath.append('pubspec.yaml'))) { |
| 1748 return; | 1748 return; |
| 1749 } | 1749 } |
| 1750 | 1750 |
| 1751 var directoryPath = | 1751 var directoryPath = |
| 1752 absoluteDirectoryPath.relativeTo(TestUtils.dartDir()); | 1752 absoluteDirectoryPath.relativeTo(TestUtils.dartDir); |
| 1753 var testName = "$directoryPath"; | 1753 var testName = "$directoryPath"; |
| 1754 var displayName = '$suiteName/$testName'; | 1754 var displayName = '$suiteName/$testName'; |
| 1755 var packageName = directoryPath.filename; | 1755 var packageName = directoryPath.filename; |
| 1756 | 1756 |
| 1757 // Collect necessary paths for pubspec.yaml overrides, pub-cache, ... | 1757 // Collect necessary paths for pubspec.yaml overrides, pub-cache, ... |
| 1758 var checkoutDir = | 1758 var checkoutDir = |
| 1759 createPubPackageBuildsDirectory(absoluteDirectoryPath); | 1759 createPubPackageBuildsDirectory(absoluteDirectoryPath); |
| 1760 var cacheDir = new Path(checkoutDir).append("pub-cache").toNativePath(); | 1760 var cacheDir = new Path(checkoutDir).append("pub-cache").toNativePath(); |
| 1761 var pubspecYamlFile = | 1761 var pubspecYamlFile = |
| 1762 new Path(checkoutDir).append('pubspec.yaml').toNativePath(); | 1762 new Path(checkoutDir).append('pubspec.yaml').toNativePath(); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1811 localSampleDirectories.forEach(enqueueTestCase); | 1811 localSampleDirectories.forEach(enqueueTestCase); |
| 1812 | 1812 |
| 1813 // Notify we're done | 1813 // Notify we're done |
| 1814 if (onDone != null) onDone(); | 1814 if (onDone != null) onDone(); |
| 1815 } | 1815 } |
| 1816 | 1816 |
| 1817 doTest = onTest; | 1817 doTest = onTest; |
| 1818 Map<String, String> _localPackageDirectories; | 1818 Map<String, String> _localPackageDirectories; |
| 1819 Map<String, String> _localSampleDirectories; | 1819 Map<String, String> _localSampleDirectories; |
| 1820 List<String> statusFiles = [ | 1820 List<String> statusFiles = [ |
| 1821 TestUtils.dartDir().join(new Path(statusFilePath)).toNativePath()]; | 1821 TestUtils.dartDir.join(new Path(statusFilePath)).toNativePath()]; |
| 1822 ReadTestExpectations(statusFiles, configuration).then((expectations) { | 1822 ReadTestExpectations(statusFiles, configuration).then((expectations) { |
| 1823 Future.wait([discoverPackagesInRepository(), | 1823 Future.wait([discoverPackagesInRepository(), |
| 1824 discoverSamplesInRepository()]).then((List results) { | 1824 discoverSamplesInRepository()]).then((List results) { |
| 1825 Map packageDirectories = results[0]; | 1825 Map packageDirectories = results[0]; |
| 1826 Map sampleDirectories = results[1]; | 1826 Map sampleDirectories = results[1]; |
| 1827 enqueueTestCases(packageDirectories, sampleDirectories, expectations); | 1827 enqueueTestCases(packageDirectories, sampleDirectories, expectations); |
| 1828 }); | 1828 }); |
| 1829 }); | 1829 }); |
| 1830 } | 1830 } |
| 1831 } | 1831 } |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1877 * The libraries in this directory relies on finding various files | 1877 * The libraries in this directory relies on finding various files |
| 1878 * relative to the 'test.dart' script in '.../dart/tools/test.dart'. If | 1878 * relative to the 'test.dart' script in '.../dart/tools/test.dart'. If |
| 1879 * the main script using 'test_suite.dart' is not there, the main | 1879 * the main script using 'test_suite.dart' is not there, the main |
| 1880 * script must set this to '.../dart/tools/test.dart'. | 1880 * script must set this to '.../dart/tools/test.dart'. |
| 1881 */ | 1881 */ |
| 1882 static String testScriptPath = new Path(Platform.script.path).toNativePath(); | 1882 static String testScriptPath = new Path(Platform.script.path).toNativePath(); |
| 1883 static LastModifiedCache lastModifiedCache = new LastModifiedCache(); | 1883 static LastModifiedCache lastModifiedCache = new LastModifiedCache(); |
| 1884 static ExistsCache existsCache = new ExistsCache(); | 1884 static ExistsCache existsCache = new ExistsCache(); |
| 1885 static Path currentWorkingDirectory = | 1885 static Path currentWorkingDirectory = |
| 1886 new Path(Directory.current.path); | 1886 new Path(Directory.current.path); |
| 1887 static Path dartDir = new Path(new File(testScriptPath).absolute.path) |
| 1888 .directoryPath.directoryPath; |
| 1889 |
| 1887 /** | 1890 /** |
| 1888 * Creates a directory using a [relativePath] to an existing | 1891 * Creates a directory using a [relativePath] to an existing |
| 1889 * [base] directory if that [relativePath] does not already exist. | 1892 * [base] directory if that [relativePath] does not already exist. |
| 1890 */ | 1893 */ |
| 1891 static Directory mkdirRecursive(Path base, Path relativePath) { | 1894 static Directory mkdirRecursive(Path base, Path relativePath) { |
| 1892 if (relativePath.isAbsolute) { | 1895 if (relativePath.isAbsolute) { |
| 1893 base = new Path('/'); | 1896 base = new Path('/'); |
| 1894 } | 1897 } |
| 1895 Directory dir = new Directory(base.toNativePath()); | 1898 Directory dir = new Directory(base.toNativePath()); |
| 1896 assert(dir.existsSync()); | 1899 assert(dir.existsSync()); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1977 if (system == 'linux') { | 1980 if (system == 'linux') { |
| 1978 result = 'out/'; | 1981 result = 'out/'; |
| 1979 } else if (system == 'macos') { | 1982 } else if (system == 'macos') { |
| 1980 result = 'xcodebuild/'; | 1983 result = 'xcodebuild/'; |
| 1981 } else if (system == 'windows') { | 1984 } else if (system == 'windows') { |
| 1982 result = 'build/'; | 1985 result = 'build/'; |
| 1983 } | 1986 } |
| 1984 return result; | 1987 return result; |
| 1985 } | 1988 } |
| 1986 | 1989 |
| 1987 static Path dartDir() { | |
| 1988 File scriptFile = new File(testScriptPath); | |
| 1989 Path scriptPath = new Path(scriptFile.absolute.path); | |
| 1990 return scriptPath.directoryPath.directoryPath; | |
| 1991 } | |
| 1992 | |
| 1993 static List<String> standardOptions(Map configuration) { | 1990 static List<String> standardOptions(Map configuration) { |
| 1994 List args = ["--ignore-unrecognized-flags"]; | 1991 List args = ["--ignore-unrecognized-flags"]; |
| 1995 if (configuration["checked"]) { | 1992 if (configuration["checked"]) { |
| 1996 args.add('--enable_asserts'); | 1993 args.add('--enable_asserts'); |
| 1997 args.add("--enable_type_checks"); | 1994 args.add("--enable_type_checks"); |
| 1998 } | 1995 } |
| 1999 String compiler = configuration["compiler"]; | 1996 String compiler = configuration["compiler"]; |
| 2000 if (compiler == "dart2js" || compiler == "dart2dart") { | 1997 if (compiler == "dart2js" || compiler == "dart2dart") { |
| 2001 args = []; | 1998 args = []; |
| 2002 if (configuration["checked"]) { | 1999 if (configuration["checked"]) { |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2074 return normal; | 2071 return normal; |
| 2075 } | 2072 } |
| 2076 | 2073 |
| 2077 static String configurationDir(Map configuration) { | 2074 static String configurationDir(Map configuration) { |
| 2078 // For regular dart checkouts, the configDir by default is mode+arch. | 2075 // For regular dart checkouts, the configDir by default is mode+arch. |
| 2079 // For Dartium, the configDir by default is mode (as defined by the Chrome | 2076 // For Dartium, the configDir by default is mode (as defined by the Chrome |
| 2080 // build setup). We can detect this because in the dartium checkout, the | 2077 // build setup). We can detect this because in the dartium checkout, the |
| 2081 // "output" directory is a sibling of the dart directory instead of a child. | 2078 // "output" directory is a sibling of the dart directory instead of a child. |
| 2082 var mode = (configuration['mode'] == 'debug') ? 'Debug' : 'Release'; | 2079 var mode = (configuration['mode'] == 'debug') ? 'Debug' : 'Release'; |
| 2083 var arch = configuration['arch'].toUpperCase(); | 2080 var arch = configuration['arch'].toUpperCase(); |
| 2084 if (currentWorkingDirectory != dartDir()) { | 2081 if (currentWorkingDirectory != dartDir) { |
| 2085 return getValidOutputDir(configuration, mode, arch); | 2082 return getValidOutputDir(configuration, mode, arch); |
| 2086 } else { | 2083 } else { |
| 2087 return mode; | 2084 return mode; |
| 2088 } | 2085 } |
| 2089 } | 2086 } |
| 2090 | 2087 |
| 2091 /** | 2088 /** |
| 2092 * Returns the path to the dart binary checked into the repo, used for | 2089 * Returns the path to the dart binary checked into the repo, used for |
| 2093 * bootstrapping test.dart. | 2090 * bootstrapping test.dart. |
| 2094 */ | 2091 */ |
| 2095 static Path get dartTestExecutable { | 2092 static Path get dartTestExecutable { |
| 2096 var path = '${TestUtils.dartDir()}/tools/testing/bin/' | 2093 var path = '$dartDir/tools/testing/bin/' |
| 2097 '${Platform.operatingSystem}/dart'; | 2094 '${Platform.operatingSystem}/dart'; |
| 2098 if (Platform.operatingSystem == 'windows') { | 2095 if (Platform.operatingSystem == 'windows') { |
| 2099 path = '$path.exe'; | 2096 path = '$path.exe'; |
| 2100 } | 2097 } |
| 2101 return new Path(path); | 2098 return new Path(path); |
| 2102 } | 2099 } |
| 2103 | 2100 |
| 2104 /** | 2101 /** |
| 2105 * Gets extra vm options passed to the testing script. | 2102 * Gets extra vm options passed to the testing script. |
| 2106 */ | 2103 */ |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2219 * $pass tests are expected to pass | 2216 * $pass tests are expected to pass |
| 2220 * $failOk tests are expected to fail that we won't fix | 2217 * $failOk tests are expected to fail that we won't fix |
| 2221 * $fail tests are expected to fail that we should fix | 2218 * $fail tests are expected to fail that we should fix |
| 2222 * $crash tests are expected to crash that we should fix | 2219 * $crash tests are expected to crash that we should fix |
| 2223 * $timeout tests are allowed to timeout | 2220 * $timeout tests are allowed to timeout |
| 2224 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 2221 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 2225 """; | 2222 """; |
| 2226 print(report); | 2223 print(report); |
| 2227 } | 2224 } |
| 2228 } | 2225 } |
| OLD | NEW |