| 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 library test_suite; | 15 library test_suite; |
| 16 | 16 |
| 17 import "dart:async"; | 17 import "dart:async"; |
| 18 import "dart:io"; | 18 import "dart:io"; |
| 19 import "dart:math"; | 19 import "dart:math"; |
| 20 import "drt_updater.dart"; | 20 import "drt_updater.dart"; |
| 21 import "html_test.dart" as htmlTest; | 21 import "html_test.dart" as htmlTest; |
| 22 import "path.dart"; | 22 import "path.dart"; |
| 23 import "multitest.dart"; | 23 import "multitest.dart"; |
| 24 import "status_file_parser.dart"; | 24 import "status_file_parser.dart"; |
| 25 import "summary_report.dart"; | 25 import "summary_report.dart"; |
| 26 import "test_runner.dart"; | 26 import "test_runner.dart"; |
| 27 import "utils.dart"; | 27 import "utils.dart"; |
| 28 import "http_server.dart" show PREFIX_BUILDDIR, PREFIX_DARTDIR; | 28 import "http_server.dart" show PREFIX_BUILDDIR, PREFIX_DARTDIR; |
| 29 | 29 |
| 30 import "compiler_configuration.dart" show | 30 import "compiler_configuration.dart" |
| 31 CommandArtifact, | 31 show CommandArtifact, CompilerConfiguration; |
| 32 CompilerConfiguration; | |
| 33 | 32 |
| 34 import "runtime_configuration.dart" show | 33 import "runtime_configuration.dart" show RuntimeConfiguration; |
| 35 RuntimeConfiguration; | |
| 36 | 34 |
| 37 import 'browser_test.dart'; | 35 import 'browser_test.dart'; |
| 38 | 36 |
| 39 | |
| 40 RegExp multiHtmlTestGroupRegExp = new RegExp(r"\s*[^/]\s*group\('[^,']*"); | 37 RegExp multiHtmlTestGroupRegExp = new RegExp(r"\s*[^/]\s*group\('[^,']*"); |
| 41 RegExp multiHtmlTestRegExp = new RegExp(r"useHtmlIndividualConfiguration()"); | 38 RegExp multiHtmlTestRegExp = new RegExp(r"useHtmlIndividualConfiguration()"); |
| 42 // Require at least one non-space character before '///' | 39 // Require at least one non-space character before '///' |
| 43 RegExp multiTestRegExp = new RegExp(r"\S *" | 40 RegExp multiTestRegExp = new RegExp(r"\S *" |
| 44 r"/// \w+:(.*)"); | 41 r"/// \w+:(.*)"); |
| 45 RegExp dartExtension = new RegExp(r'\.dart$'); | 42 RegExp dartExtension = new RegExp(r'\.dart$'); |
| 46 | 43 |
| 47 /** | 44 /** |
| 48 * A simple function that tests [arg] and returns `true` or `false`. | 45 * A simple function that tests [arg] and returns `true` or `false`. |
| 49 */ | 46 */ |
| 50 typedef bool Predicate<T>(T arg); | 47 typedef bool Predicate<T>(T arg); |
| 51 | 48 |
| 52 typedef void CreateTest(Path filePath, | 49 typedef void CreateTest(Path filePath, Path originTestPath, |
| 53 Path originTestPath, | 50 bool hasCompileError, bool hasRuntimeError, |
| 54 bool hasCompileError, | 51 {bool isNegativeIfChecked, |
| 55 bool hasRuntimeError, | 52 bool hasCompileErrorIfChecked, |
| 56 {bool isNegativeIfChecked, | 53 bool hasStaticWarning, |
| 57 bool hasCompileErrorIfChecked, | 54 String multitestKey}); |
| 58 bool hasStaticWarning, | |
| 59 String multitestKey}); | |
| 60 | 55 |
| 61 typedef void VoidFunction(); | 56 typedef void VoidFunction(); |
| 62 | 57 |
| 63 /** | 58 /** |
| 64 * Calls [function] asynchronously. Returns a future that completes with the | 59 * Calls [function] asynchronously. Returns a future that completes with the |
| 65 * result of the function. If the function is `null`, returns a future that | 60 * result of the function. If the function is `null`, returns a future that |
| 66 * completes immediately with `null`. | 61 * completes immediately with `null`. |
| 67 */ | 62 */ |
| 68 Future asynchronously(function()) { | 63 Future asynchronously(function()) { |
| 69 if (function == null) return new Future.value(null); | 64 if (function == null) return new Future.value(null); |
| 70 | 65 |
| 71 var completer = new Completer(); | 66 var completer = new Completer(); |
| 72 Timer.run(() => completer.complete(function())); | 67 Timer.run(() => completer.complete(function())); |
| 73 | 68 |
| 74 return completer.future; | 69 return completer.future; |
| 75 } | 70 } |
| 76 | 71 |
| 77 | |
| 78 /** A completer that waits until all added [Future]s complete. */ | 72 /** A completer that waits until all added [Future]s complete. */ |
| 79 // TODO(rnystrom): Copied from web_components. Remove from here when it gets | 73 // TODO(rnystrom): Copied from web_components. Remove from here when it gets |
| 80 // added to dart:core. (See #6626.) | 74 // added to dart:core. (See #6626.) |
| 81 class FutureGroup { | 75 class FutureGroup { |
| 82 static const _FINISHED = -1; | 76 static const _FINISHED = -1; |
| 83 int _pending = 0; | 77 int _pending = 0; |
| 84 Completer<List> _completer = new Completer<List>(); | 78 Completer<List> _completer = new Completer<List>(); |
| 85 final List<Future> futures = <Future>[]; | 79 final List<Future> futures = <Future>[]; |
| 86 bool wasCompleted = false; | 80 bool wasCompleted = false; |
| 87 | 81 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 109 wasCompleted = true; | 103 wasCompleted = true; |
| 110 } | 104 } |
| 111 } | 105 } |
| 112 }); | 106 }); |
| 113 futures.add(handledTaskFuture); | 107 futures.add(handledTaskFuture); |
| 114 } | 108 } |
| 115 | 109 |
| 116 Future<List> get future => _completer.future; | 110 Future<List> get future => _completer.future; |
| 117 } | 111 } |
| 118 | 112 |
| 119 | |
| 120 /** | 113 /** |
| 121 * A TestSuite represents a collection of tests. It creates a [TestCase] | 114 * A TestSuite represents a collection of tests. It creates a [TestCase] |
| 122 * object for each test to be run, and passes the test cases to a callback. | 115 * object for each test to be run, and passes the test cases to a callback. |
| 123 * | 116 * |
| 124 * Most TestSuites represent a directory or directory tree containing tests, | 117 * Most TestSuites represent a directory or directory tree containing tests, |
| 125 * and a status file containing the expected results when these tests are run. | 118 * and a status file containing the expected results when these tests are run. |
| 126 */ | 119 */ |
| 127 abstract class TestSuite { | 120 abstract class TestSuite { |
| 128 final Map configuration; | 121 final Map configuration; |
| 129 final String suiteName; | 122 final String suiteName; |
| 130 // This function is set by subclasses before enqueueing starts. | 123 // This function is set by subclasses before enqueueing starts. |
| 131 Function doTest; | 124 Function doTest; |
| 132 Map<String, String> _environmentOverrides; | 125 Map<String, String> _environmentOverrides; |
| 133 | 126 |
| 134 TestSuite(this.configuration, this.suiteName) { | 127 TestSuite(this.configuration, this.suiteName) { |
| 135 TestUtils.buildDir(configuration); // Sets configuration_directory. | 128 TestUtils.buildDir(configuration); // Sets configuration_directory. |
| 136 if (configuration['configuration_directory'] != null) { | 129 if (configuration['configuration_directory'] != null) { |
| 137 _environmentOverrides = { | 130 _environmentOverrides = { |
| 138 'DART_CONFIGURATION' : configuration['configuration_directory'] | 131 'DART_CONFIGURATION': configuration['configuration_directory'] |
| 139 }; | 132 }; |
| 140 } | 133 } |
| 141 } | 134 } |
| 142 | 135 |
| 143 Map<String, String> get environmentOverrides => _environmentOverrides; | 136 Map<String, String> get environmentOverrides => _environmentOverrides; |
| 144 | 137 |
| 145 /** | 138 /** |
| 146 * Whether or not binaries should be found in the root build directory or | 139 * Whether or not binaries should be found in the root build directory or |
| 147 * in the built SDK. | 140 * in the built SDK. |
| 148 */ | 141 */ |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 if (!optionsName.isEmpty) { | 345 if (!optionsName.isEmpty) { |
| 353 testUniqueName = '$testUniqueName-$optionsName'; | 346 testUniqueName = '$testUniqueName-$optionsName'; |
| 354 } | 347 } |
| 355 | 348 |
| 356 Path generatedTestPath = new Path(buildDir) | 349 Path generatedTestPath = new Path(buildDir) |
| 357 .append('generated_$name') | 350 .append('generated_$name') |
| 358 .append(dirname) | 351 .append(dirname) |
| 359 .append(testUniqueName); | 352 .append(testUniqueName); |
| 360 | 353 |
| 361 TestUtils.mkdirRecursive(new Path('.'), generatedTestPath); | 354 TestUtils.mkdirRecursive(new Path('.'), generatedTestPath); |
| 362 return new File(generatedTestPath.toNativePath()).absolute.path | 355 return new File(generatedTestPath.toNativePath()) |
| 356 .absolute |
| 357 .path |
| 363 .replaceAll('\\', '/'); | 358 .replaceAll('\\', '/'); |
| 364 } | 359 } |
| 365 | 360 |
| 366 String buildTestCaseDisplayName(Path suiteDir, | 361 String buildTestCaseDisplayName(Path suiteDir, Path originTestPath, |
| 367 Path originTestPath, | 362 {String multitestName: ""}) { |
| 368 {String multitestName: ""}) { | |
| 369 Path testNamePath = originTestPath.relativeTo(suiteDir); | 363 Path testNamePath = originTestPath.relativeTo(suiteDir); |
| 370 var directory = testNamePath.directoryPath; | 364 var directory = testNamePath.directoryPath; |
| 371 var filenameWithoutExt = testNamePath.filenameWithoutExtension; | 365 var filenameWithoutExt = testNamePath.filenameWithoutExtension; |
| 372 | 366 |
| 373 String concat(String base, String part) { | 367 String concat(String base, String part) { |
| 374 if (base == "") return part; | 368 if (base == "") return part; |
| 375 if (part == "") return base; | 369 if (part == "") return base; |
| 376 return "$base/$part"; | 370 return "$base/$part"; |
| 377 } | 371 } |
| 378 | 372 |
| 379 var testName = "$directory"; | 373 var testName = "$directory"; |
| 380 testName = concat(testName, "$filenameWithoutExt"); | 374 testName = concat(testName, "$filenameWithoutExt"); |
| 381 testName = concat(testName, multitestName); | 375 testName = concat(testName, multitestName); |
| 382 return testName; | 376 return testName; |
| 383 } | 377 } |
| 384 | 378 |
| 385 /** | 379 /** |
| 386 * Create a directories for generated assets (tests, html files, | 380 * Create a directories for generated assets (tests, html files, |
| 387 * pubspec checkouts ...). | 381 * pubspec checkouts ...). |
| 388 */ | 382 */ |
| 389 | 383 |
| 390 String createOutputDirectory(Path testPath, String optionsName) { | 384 String createOutputDirectory(Path testPath, String optionsName) { |
| 391 var checked = configuration['checked'] ? '-checked' : ''; | 385 var checked = configuration['checked'] ? '-checked' : ''; |
| 392 var minified = configuration['minified'] ? '-minified' : ''; | 386 var minified = configuration['minified'] ? '-minified' : ''; |
| 393 var sdk = configuration['use_sdk'] ? '-sdk' : ''; | 387 var sdk = configuration['use_sdk'] ? '-sdk' : ''; |
| 394 var packages = configuration['use_public_packages'] | 388 var packages = |
| 395 ? '-public_packages' : ''; | 389 configuration['use_public_packages'] ? '-public_packages' : ''; |
| 396 var dirName = "${configuration['compiler']}-${configuration['runtime']}" | 390 var dirName = "${configuration['compiler']}-${configuration['runtime']}" |
| 397 "$checked$minified$packages$sdk"; | 391 "$checked$minified$packages$sdk"; |
| 398 return createGeneratedTestDirectoryHelper( | 392 return createGeneratedTestDirectoryHelper( |
| 399 "tests", dirName, testPath, optionsName); | 393 "tests", dirName, testPath, optionsName); |
| 400 } | 394 } |
| 401 | 395 |
| 402 String createCompilationOutputDirectory(Path testPath) { | 396 String createCompilationOutputDirectory(Path testPath) { |
| 403 var checked = configuration['checked'] ? '-checked' : ''; | 397 var checked = configuration['checked'] ? '-checked' : ''; |
| 404 var minified = configuration['minified'] ? '-minified' : ''; | 398 var minified = configuration['minified'] ? '-minified' : ''; |
| 405 var csp = configuration['csp'] ? '-csp' : ''; | 399 var csp = configuration['csp'] ? '-csp' : ''; |
| 406 var sdk = configuration['use_sdk'] ? '-sdk' : ''; | 400 var sdk = configuration['use_sdk'] ? '-sdk' : ''; |
| 407 var packages = configuration['use_public_packages'] | 401 var packages = |
| 408 ? '-public_packages' : ''; | 402 configuration['use_public_packages'] ? '-public_packages' : ''; |
| 409 var dirName = "${configuration['compiler']}" | 403 var dirName = "${configuration['compiler']}" |
| 410 "$checked$minified$csp$packages$sdk"; | 404 "$checked$minified$csp$packages$sdk"; |
| 411 return createGeneratedTestDirectoryHelper( | 405 return createGeneratedTestDirectoryHelper( |
| 412 "compilations", dirName, testPath, ""); | 406 "compilations", dirName, testPath, ""); |
| 413 } | 407 } |
| 414 | 408 |
| 415 String createPubspecCheckoutDirectory(Path directoryOfPubspecYaml) { | 409 String createPubspecCheckoutDirectory(Path directoryOfPubspecYaml) { |
| 416 var sdk = configuration['use_sdk'] ? '-sdk' : ''; | 410 var sdk = configuration['use_sdk'] ? '-sdk' : ''; |
| 417 var pkg = configuration['use_public_packages'] | 411 var pkg = configuration['use_public_packages'] |
| 418 ? 'public_packages' : 'repo_packages'; | 412 ? 'public_packages' |
| 413 : 'repo_packages'; |
| 419 return createGeneratedTestDirectoryHelper( | 414 return createGeneratedTestDirectoryHelper( |
| 420 "pubspec_checkouts", '$pkg$sdk', directoryOfPubspecYaml, ""); | 415 "pubspec_checkouts", '$pkg$sdk', directoryOfPubspecYaml, ""); |
| 421 } | 416 } |
| 422 | 417 |
| 423 String createPubPackageBuildsDirectory(Path directoryOfPubspecYaml) { | 418 String createPubPackageBuildsDirectory(Path directoryOfPubspecYaml) { |
| 424 var pkg = configuration['use_public_packages'] | 419 var pkg = configuration['use_public_packages'] |
| 425 ? 'public_packages' : 'repo_packages'; | 420 ? 'public_packages' |
| 421 : 'repo_packages'; |
| 426 return createGeneratedTestDirectoryHelper( | 422 return createGeneratedTestDirectoryHelper( |
| 427 "pub_package_builds", pkg, directoryOfPubspecYaml, ""); | 423 "pub_package_builds", pkg, directoryOfPubspecYaml, ""); |
| 428 } | 424 } |
| 429 | 425 |
| 430 /** | 426 /** |
| 431 * Helper function for discovering the packages in the dart repository. | 427 * Helper function for discovering the packages in the dart repository. |
| 432 */ | 428 */ |
| 433 Future<List> listDir(Path path, Function isValid) { | 429 Future<List> listDir(Path path, Function isValid) { |
| 434 var dir = new Directory(path.toNativePath()); | 430 var dir = new Directory(path.toNativePath()); |
| 435 return dir.exists().then((var exist) { | 431 return dir.exists().then((var exist) { |
| 436 if (!exist) return []; | 432 if (!exist) return []; |
| 437 return dir.list(recursive: false) | 433 return dir |
| 438 .where((fse) => fse is Directory) | 434 .list(recursive: false) |
| 439 .map((Directory directory) { | 435 .where((fse) => fse is Directory) |
| 440 var fullPath = directory.absolute.path; | 436 .map((Directory directory) { |
| 441 var packageName = new Path(fullPath).filename; | 437 var fullPath = directory.absolute.path; |
| 442 if (isValid(packageName)) { | 438 var packageName = new Path(fullPath).filename; |
| 443 return [packageName, path.append(packageName).toNativePath()]; | 439 if (isValid(packageName)) { |
| 444 } | 440 return [packageName, path.append(packageName).toNativePath()]; |
| 445 return null; | 441 } |
| 446 }) | 442 return null; |
| 447 .where((name) => name != null) | 443 }) |
| 448 .toList(); | 444 .where((name) => name != null) |
| 449 }); | 445 .toList(); |
| 446 }); |
| 450 } | 447 } |
| 451 | 448 |
| 452 Future<Map> discoverPackagesInRepository() { | 449 Future<Map> discoverPackagesInRepository() { |
| 453 /* | 450 /* |
| 454 * Layout of packages inside the dart repository: | 451 * Layout of packages inside the dart repository: |
| 455 * dart/ | 452 * dart/ |
| 456 * pkg/PACKAGE_NAME | 453 * pkg/PACKAGE_NAME |
| 457 * third_party/pkg/PACKAGE_NAME | 454 * third_party/pkg/PACKAGE_NAME |
| 458 * runtime/observatory/PACKAGE_NAME | 455 * runtime/observatory/PACKAGE_NAME |
| 459 * sdk/lib/_internal/PACKAGE_NAME | 456 * sdk/lib/_internal/PACKAGE_NAME |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 return packageDirectories; | 512 return packageDirectories; |
| 516 }); | 513 }); |
| 517 } | 514 } |
| 518 | 515 |
| 519 /** | 516 /** |
| 520 * Helper function for building dependency_overrides for pubspec.yaml files. | 517 * Helper function for building dependency_overrides for pubspec.yaml files. |
| 521 */ | 518 */ |
| 522 Map buildPubspecDependencyOverrides(Map packageDirectories) { | 519 Map buildPubspecDependencyOverrides(Map packageDirectories) { |
| 523 Map overrides = {}; | 520 Map overrides = {}; |
| 524 packageDirectories.forEach((String packageName, String fullPath) { | 521 packageDirectories.forEach((String packageName, String fullPath) { |
| 525 overrides[packageName] = { 'path' : fullPath }; | 522 overrides[packageName] = {'path': fullPath}; |
| 526 }); | 523 }); |
| 527 return overrides; | 524 return overrides; |
| 528 } | 525 } |
| 529 | |
| 530 } | 526 } |
| 531 | 527 |
| 532 | |
| 533 Future<Iterable<String>> ccTestLister(String runnerPath) { | 528 Future<Iterable<String>> ccTestLister(String runnerPath) { |
| 534 return Process.run(runnerPath, ["--list"]).then((ProcessResult result) { | 529 return Process.run(runnerPath, ["--list"]).then((ProcessResult result) { |
| 535 if (result.exitCode != 0) { | 530 if (result.exitCode != 0) { |
| 536 throw "Failed to list tests: '$runnerPath --list'. " | 531 throw "Failed to list tests: '$runnerPath --list'. " |
| 537 "Process exited with ${result.exitCode}"; | 532 "Process exited with ${result.exitCode}"; |
| 538 } | 533 } |
| 539 return result.stdout | 534 return result.stdout |
| 540 .split('\n') | 535 .split('\n') |
| 541 .map((line) => line.trim()) | 536 .map((line) => line.trim()) |
| 542 .where((name) => name.length > 0); | 537 .where((name) => name.length > 0); |
| 543 }); | 538 }); |
| 544 } | 539 } |
| 545 | 540 |
| 546 | |
| 547 /** | 541 /** |
| 548 * A specialized [TestSuite] that runs tests written in C to unit test | 542 * A specialized [TestSuite] that runs tests written in C to unit test |
| 549 * the Dart virtual machine and its API. | 543 * the Dart virtual machine and its API. |
| 550 * | 544 * |
| 551 * The tests are compiled into a monolithic executable by the build step. | 545 * The tests are compiled into a monolithic executable by the build step. |
| 552 * The executable lists its tests when run with the --list command line flag. | 546 * The executable lists its tests when run with the --list command line flag. |
| 553 * Individual tests are run by specifying them on the command line. | 547 * Individual tests are run by specifying them on the command line. |
| 554 */ | 548 */ |
| 555 class CCTestSuite extends TestSuite { | 549 class CCTestSuite extends TestSuite { |
| 556 final String testPrefix; | 550 final String testPrefix; |
| 557 String targetRunnerPath; | 551 String targetRunnerPath; |
| 558 String hostRunnerPath; | 552 String hostRunnerPath; |
| 559 final String dartDir; | 553 final String dartDir; |
| 560 List<String> statusFilePaths; | 554 List<String> statusFilePaths; |
| 561 | 555 |
| 562 CCTestSuite(Map configuration, | 556 CCTestSuite(Map configuration, String suiteName, String runnerName, |
| 563 String suiteName, | 557 this.statusFilePaths, |
| 564 String runnerName, | 558 {this.testPrefix: ''}) |
| 565 this.statusFilePaths, | |
| 566 {this.testPrefix: ''}) | |
| 567 : super(configuration, suiteName), | 559 : super(configuration, suiteName), |
| 568 dartDir = TestUtils.dartDir.toNativePath() { | 560 dartDir = TestUtils.dartDir.toNativePath() { |
| 569 // For running the tests we use the given '$runnerName' binary | 561 // For running the tests we use the given '$runnerName' binary |
| 570 targetRunnerPath = '$buildDir/$runnerName'; | 562 targetRunnerPath = '$buildDir/$runnerName'; |
| 571 | 563 |
| 572 // For listing the tests we use the '$runnerName.host' binary if it exists | 564 // For listing the tests we use the '$runnerName.host' binary if it exists |
| 573 // and use '$runnerName' if it doesn't. | 565 // and use '$runnerName' if it doesn't. |
| 574 var binarySuffix = Platform.operatingSystem == 'windows' ? '.exe' : ''; | 566 var binarySuffix = Platform.operatingSystem == 'windows' ? '.exe' : ''; |
| 575 var hostBinary = '$targetRunnerPath.host$binarySuffix'; | 567 var hostBinary = '$targetRunnerPath.host$binarySuffix'; |
| 576 if (new File(hostBinary).existsSync()) { | 568 if (new File(hostBinary).existsSync()) { |
| 577 hostRunnerPath = hostBinary; | 569 hostRunnerPath = hostBinary; |
| 578 } else { | 570 } else { |
| 579 hostRunnerPath = targetRunnerPath; | 571 hostRunnerPath = targetRunnerPath; |
| 580 } | 572 } |
| 581 } | 573 } |
| 582 | 574 |
| 583 void testNameHandler(TestExpectations testExpectations, String testName) { | 575 void testNameHandler(TestExpectations testExpectations, String testName) { |
| 584 // Only run the tests that match the pattern. Use the name | 576 // Only run the tests that match the pattern. Use the name |
| 585 // "suiteName/testName" for cc tests. | 577 // "suiteName/testName" for cc tests. |
| 586 String constructedName = '$suiteName/$testPrefix$testName'; | 578 String constructedName = '$suiteName/$testPrefix$testName'; |
| 587 | 579 |
| 588 var expectations = testExpectations.expectations( | 580 var expectations = testExpectations.expectations('$testPrefix$testName'); |
| 589 '$testPrefix$testName'); | |
| 590 | 581 |
| 591 var args = TestUtils.standardOptions(configuration); | 582 var args = TestUtils.standardOptions(configuration); |
| 592 args.add(testName); | 583 args.add(testName); |
| 593 | 584 |
| 594 var command = CommandBuilder.instance.getProcessCommand( | 585 var command = CommandBuilder.instance.getProcessCommand( |
| 595 'run_vm_unittest', targetRunnerPath, args, environmentOverrides); | 586 'run_vm_unittest', targetRunnerPath, args, environmentOverrides); |
| 596 enqueueNewTestCase( | 587 enqueueNewTestCase( |
| 597 new TestCase(constructedName, [command], configuration, expectations)); | 588 new TestCase(constructedName, [command], configuration, expectations)); |
| 598 } | 589 } |
| 599 | 590 |
| 600 void forEachTest(Function onTest, Map testCache, [VoidFunction onDone]) { | 591 void forEachTest(Function onTest, Map testCache, [VoidFunction onDone]) { |
| 601 doTest = onTest; | 592 doTest = onTest; |
| 602 var statusFiles = | 593 var statusFiles = |
| 603 statusFilePaths.map((statusFile) => "$dartDir/$statusFile").toList(); | 594 statusFilePaths.map((statusFile) => "$dartDir/$statusFile").toList(); |
| 604 | 595 |
| 605 ReadTestExpectations(statusFiles, configuration) | 596 ReadTestExpectations(statusFiles, configuration) |
| 606 .then((TestExpectations expectations) { | 597 .then((TestExpectations expectations) { |
| 607 ccTestLister(hostRunnerPath).then((Iterable<String> names) { | 598 ccTestLister(hostRunnerPath).then((Iterable<String> names) { |
| 608 names.forEach((testName) => testNameHandler(expectations, testName)); | 599 names.forEach((testName) => testNameHandler(expectations, testName)); |
| 609 doTest = null; | 600 doTest = null; |
| 610 if (onDone != null) onDone(); | 601 if (onDone != null) onDone(); |
| 611 }).catchError((error) { | 602 }).catchError((error) { |
| 612 print("Fatal error occured: $error"); | 603 print("Fatal error occured: $error"); |
| 613 exit(1); | 604 exit(1); |
| 614 }); | 605 }); |
| 615 }); | 606 }); |
| 616 } | 607 } |
| 617 } | 608 } |
| 618 | 609 |
| 619 | |
| 620 class TestInformation { | 610 class TestInformation { |
| 621 Path filePath; | 611 Path filePath; |
| 622 Path originTestPath; | 612 Path originTestPath; |
| 623 Map optionsFromFile; | 613 Map optionsFromFile; |
| 624 bool hasCompileError; | 614 bool hasCompileError; |
| 625 bool hasRuntimeError; | 615 bool hasRuntimeError; |
| 626 bool isNegativeIfChecked; | 616 bool isNegativeIfChecked; |
| 627 bool hasCompileErrorIfChecked; | 617 bool hasCompileErrorIfChecked; |
| 628 bool hasStaticWarning; | 618 bool hasStaticWarning; |
| 629 String multitestKey; | 619 String multitestKey; |
| 630 | 620 |
| 631 TestInformation(this.filePath, this.originTestPath, this.optionsFromFile, | 621 TestInformation( |
| 632 this.hasCompileError, this.hasRuntimeError, | 622 this.filePath, |
| 633 this.isNegativeIfChecked, this.hasCompileErrorIfChecked, | 623 this.originTestPath, |
| 634 this.hasStaticWarning, | 624 this.optionsFromFile, |
| 635 {this.multitestKey: ''}) { | 625 this.hasCompileError, |
| 626 this.hasRuntimeError, |
| 627 this.isNegativeIfChecked, |
| 628 this.hasCompileErrorIfChecked, |
| 629 this.hasStaticWarning, |
| 630 {this.multitestKey: ''}) { |
| 636 assert(filePath.isAbsolute); | 631 assert(filePath.isAbsolute); |
| 637 } | 632 } |
| 638 } | 633 } |
| 639 | 634 |
| 640 | |
| 641 class HtmlTestInformation extends TestInformation { | 635 class HtmlTestInformation extends TestInformation { |
| 642 List<String> expectedMessages; | 636 List<String> expectedMessages; |
| 643 List<String> scripts; | 637 List<String> scripts; |
| 644 | 638 |
| 645 HtmlTestInformation(Path filePath, this.expectedMessages, this.scripts) | 639 HtmlTestInformation(Path filePath, this.expectedMessages, this.scripts) |
| 646 : super(filePath, filePath, | 640 : super( |
| 647 {'isMultitest': false, 'isMultiHtmlTest': false}, | 641 filePath, |
| 648 false, false, false, false, false) {} | 642 filePath, |
| 643 {'isMultitest': false, 'isMultiHtmlTest': false}, |
| 644 false, |
| 645 false, |
| 646 false, |
| 647 false, |
| 648 false) {} |
| 649 } | 649 } |
| 650 | 650 |
| 651 | |
| 652 /** | 651 /** |
| 653 * A standard [TestSuite] implementation that searches for tests in a | 652 * A standard [TestSuite] implementation that searches for tests in a |
| 654 * directory, and creates [TestCase]s that compile and/or run them. | 653 * directory, and creates [TestCase]s that compile and/or run them. |
| 655 */ | 654 */ |
| 656 class StandardTestSuite extends TestSuite { | 655 class StandardTestSuite extends TestSuite { |
| 657 final Path suiteDir; | 656 final Path suiteDir; |
| 658 final List<String> statusFilePaths; | 657 final List<String> statusFilePaths; |
| 659 TestExpectations testExpectations; | 658 TestExpectations testExpectations; |
| 660 List<TestInformation> cachedTests; | 659 List<TestInformation> cachedTests; |
| 661 final Path dartDir; | 660 final Path dartDir; |
| 662 Predicate<String> isTestFilePredicate; | 661 Predicate<String> isTestFilePredicate; |
| 663 final bool listRecursively; | 662 final bool listRecursively; |
| 664 final extraVmOptions; | 663 final extraVmOptions; |
| 665 List<Uri> _dart2JsBootstrapDependencies; | 664 List<Uri> _dart2JsBootstrapDependencies; |
| 666 | 665 |
| 667 StandardTestSuite(Map configuration, | 666 StandardTestSuite(Map configuration, String suiteName, Path suiteDirectory, |
| 668 String suiteName, | 667 this.statusFilePaths, |
| 669 Path suiteDirectory, | 668 {this.isTestFilePredicate, bool recursive: false}) |
| 670 this.statusFilePaths, | |
| 671 {this.isTestFilePredicate, | |
| 672 bool recursive: false}) | |
| 673 : super(configuration, suiteName), | 669 : super(configuration, suiteName), |
| 674 dartDir = TestUtils.dartDir, | 670 dartDir = TestUtils.dartDir, |
| 675 listRecursively = recursive, | 671 listRecursively = recursive, |
| 676 suiteDir = TestUtils.dartDir.join(suiteDirectory), | 672 suiteDir = TestUtils.dartDir.join(suiteDirectory), |
| 677 extraVmOptions = TestUtils.getExtraVmOptions(configuration) { | 673 extraVmOptions = TestUtils.getExtraVmOptions(configuration) { |
| 678 if (!useSdk) { | 674 if (!useSdk) { |
| 679 _dart2JsBootstrapDependencies = []; | 675 _dart2JsBootstrapDependencies = []; |
| 680 } else { | 676 } else { |
| 681 var snapshotPath = TestUtils.absolutePath(new Path(buildDir).join( | 677 var snapshotPath = TestUtils |
| 682 new Path('dart-sdk/bin/snapshots/' | 678 .absolutePath( |
| 683 'utils_wrapper.dart.snapshot'))).toString(); | 679 new Path(buildDir).join(new Path('dart-sdk/bin/snapshots/' |
| 684 _dart2JsBootstrapDependencies = | 680 'utils_wrapper.dart.snapshot'))) |
| 685 [new Uri(scheme: 'file', path: snapshotPath)]; | 681 .toString(); |
| 682 _dart2JsBootstrapDependencies = [ |
| 683 new Uri(scheme: 'file', path: snapshotPath) |
| 684 ]; |
| 686 } | 685 } |
| 687 } | 686 } |
| 688 | 687 |
| 689 /** | 688 /** |
| 690 * Creates a test suite whose file organization matches an expected structure. | 689 * Creates a test suite whose file organization matches an expected structure. |
| 691 * To use this, your suite should look like: | 690 * To use this, your suite should look like: |
| 692 * | 691 * |
| 693 * dart/ | 692 * dart/ |
| 694 * path/ | 693 * path/ |
| 695 * to/ | 694 * to/ |
| (...skipping 12 matching lines...) Expand all Loading... |
| 708 * If you follow that convention, then you can construct one of these like: | 707 * If you follow that convention, then you can construct one of these like: |
| 709 * | 708 * |
| 710 * new StandardTestSuite.forDirectory(configuration, 'path/to/mytestsuite'); | 709 * new StandardTestSuite.forDirectory(configuration, 'path/to/mytestsuite'); |
| 711 * | 710 * |
| 712 * instead of having to create a custom [StandardTestSuite] subclass. In | 711 * instead of having to create a custom [StandardTestSuite] subclass. In |
| 713 * particular, if you add 'path/to/mytestsuite' to [TEST_SUITE_DIRECTORIES] | 712 * particular, if you add 'path/to/mytestsuite' to [TEST_SUITE_DIRECTORIES] |
| 714 * in test.dart, this will all be set up for you. | 713 * in test.dart, this will all be set up for you. |
| 715 */ | 714 */ |
| 716 factory StandardTestSuite.forDirectory(Map configuration, Path directory) { | 715 factory StandardTestSuite.forDirectory(Map configuration, Path directory) { |
| 717 var name = directory.filename; | 716 var name = directory.filename; |
| 718 var status_paths = ['$directory/$name.status', | 717 var status_paths = [ |
| 719 '$directory/.status', | 718 '$directory/$name.status', |
| 720 '$directory/${name}_dart2js.status', | 719 '$directory/.status', |
| 721 '$directory/${name}_analyzer2.status']; | 720 '$directory/${name}_dart2js.status', |
| 721 '$directory/${name}_analyzer2.status' |
| 722 ]; |
| 722 | 723 |
| 723 return new StandardTestSuite(configuration, | 724 return new StandardTestSuite(configuration, name, directory, status_paths, |
| 724 name, directory, | |
| 725 status_paths, | |
| 726 isTestFilePredicate: (filename) => filename.endsWith('_test.dart'), | 725 isTestFilePredicate: (filename) => filename.endsWith('_test.dart'), |
| 727 recursive: true); | 726 recursive: true); |
| 728 } | 727 } |
| 729 | 728 |
| 730 List<Uri> get dart2JsBootstrapDependencies => _dart2JsBootstrapDependencies; | 729 List<Uri> get dart2JsBootstrapDependencies => _dart2JsBootstrapDependencies; |
| 731 | 730 |
| 732 /** | 731 /** |
| 733 * The default implementation assumes a file is a test if | 732 * The default implementation assumes a file is a test if |
| 734 * it ends in "Test.dart". | 733 * it ends in "Test.dart". |
| 735 */ | 734 */ |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 816 return new Future.value(null); | 815 return new Future.value(null); |
| 817 } else { | 816 } else { |
| 818 var group = new FutureGroup(); | 817 var group = new FutureGroup(); |
| 819 enqueueDirectory(dir, group); | 818 enqueueDirectory(dir, group); |
| 820 return group.future; | 819 return group.future; |
| 821 } | 820 } |
| 822 }); | 821 }); |
| 823 } | 822 } |
| 824 | 823 |
| 825 void enqueueDirectory(Directory dir, FutureGroup group) { | 824 void enqueueDirectory(Directory dir, FutureGroup group) { |
| 826 var lister = dir.list(recursive: listRecursively) | 825 var lister = dir |
| 826 .list(recursive: listRecursively) |
| 827 .where((fse) => fse is File) | 827 .where((fse) => fse is File) |
| 828 .forEach((File f) { | 828 .forEach((File f) { |
| 829 enqueueFile(f.path, group); | 829 enqueueFile(f.path, group); |
| 830 }); | 830 }); |
| 831 group.add(lister); | 831 group.add(lister); |
| 832 } | 832 } |
| 833 | 833 |
| 834 void enqueueFile(String filename, FutureGroup group) { | 834 void enqueueFile(String filename, FutureGroup group) { |
| 835 if (isHtmlTestFile(filename)) { | 835 if (isHtmlTestFile(filename)) { |
| 836 var info = htmlTest.getInformation(filename); | 836 var info = htmlTest.getInformation(filename); |
| 837 if (info == null) { | 837 if (info == null) { |
| 838 DebugLogger.error( | 838 DebugLogger |
| 839 "HtmlTest $filename does not contain required annotations"); | 839 .error("HtmlTest $filename does not contain required annotations"); |
| 840 return; | 840 return; |
| 841 } | 841 } |
| 842 cachedTests.add(info); | 842 cachedTests.add(info); |
| 843 enqueueTestCaseFromTestInformation(info); | 843 enqueueTestCaseFromTestInformation(info); |
| 844 return; | 844 return; |
| 845 } | 845 } |
| 846 if (!isTestFile(filename)) return; | 846 if (!isTestFile(filename)) return; |
| 847 Path filePath = new Path(filename); | 847 Path filePath = new Path(filename); |
| 848 | 848 |
| 849 var optionsFromFile = readOptionsFromFile(filePath); | 849 var optionsFromFile = readOptionsFromFile(filePath); |
| 850 CreateTest createTestCase = makeTestCaseCreator(optionsFromFile); | 850 CreateTest createTestCase = makeTestCaseCreator(optionsFromFile); |
| 851 | 851 |
| 852 if (optionsFromFile['isMultitest']) { | 852 if (optionsFromFile['isMultitest']) { |
| 853 group.add(doMultitest(filePath, buildDir, suiteDir, createTestCase)); | 853 group.add(doMultitest(filePath, buildDir, suiteDir, createTestCase)); |
| 854 } else { | 854 } else { |
| 855 createTestCase(filePath, | 855 createTestCase(filePath, filePath, optionsFromFile['hasCompileError'], |
| 856 filePath, | 856 optionsFromFile['hasRuntimeError'], |
| 857 optionsFromFile['hasCompileError'], | 857 hasStaticWarning: optionsFromFile['hasStaticWarning']); |
| 858 optionsFromFile['hasRuntimeError'], | |
| 859 hasStaticWarning: optionsFromFile['hasStaticWarning']); | |
| 860 } | 858 } |
| 861 } | 859 } |
| 862 | 860 |
| 863 static Path _findPubspecYamlFile(Path filePath) { | 861 static Path _findPubspecYamlFile(Path filePath) { |
| 864 final existsCache = TestUtils.existsCache; | 862 final existsCache = TestUtils.existsCache; |
| 865 | 863 |
| 866 Path root = TestUtils.dartDir; | 864 Path root = TestUtils.dartDir; |
| 867 assert ("$filePath".startsWith("$root")); | 865 assert("$filePath".startsWith("$root")); |
| 868 | 866 |
| 869 // We start with the parent directory of [filePath] and go up until | 867 // We start with the parent directory of [filePath] and go up until |
| 870 // the root directory (excluding the root). | 868 // the root directory (excluding the root). |
| 871 List<String> segments = | 869 List<String> segments = filePath.directoryPath.relativeTo(root).segments(); |
| 872 filePath.directoryPath.relativeTo(root).segments(); | |
| 873 while (segments.length > 0) { | 870 while (segments.length > 0) { |
| 874 var pubspecYamlPath = | 871 var pubspecYamlPath = new Path(segments.join('/')).append('pubspec.yaml'); |
| 875 new Path(segments.join('/')).append('pubspec.yaml'); | |
| 876 if (existsCache.doesFileExist(pubspecYamlPath.toNativePath())) { | 872 if (existsCache.doesFileExist(pubspecYamlPath.toNativePath())) { |
| 877 return root.join(pubspecYamlPath); | 873 return root.join(pubspecYamlPath); |
| 878 } | 874 } |
| 879 segments.removeLast(); | 875 segments.removeLast(); |
| 880 } | 876 } |
| 881 return null; | 877 return null; |
| 882 } | 878 } |
| 883 | 879 |
| 884 void enqueueTestCaseFromTestInformation(TestInformation info) { | 880 void enqueueTestCaseFromTestInformation(TestInformation info) { |
| 885 String testName = buildTestCaseDisplayName(suiteDir, info.originTestPath, | 881 String testName = buildTestCaseDisplayName(suiteDir, info.originTestPath, |
| 886 multitestName: | 882 multitestName: |
| 887 info.optionsFromFile['isMultitest'] ? info.multitestKey : ""); | 883 info.optionsFromFile['isMultitest'] ? info.multitestKey : ""); |
| 888 Set<Expectation> expectations = testExpectations.expectations(testName); | 884 Set<Expectation> expectations = testExpectations.expectations(testName); |
| 889 if (info is HtmlTestInformation) { | 885 if (info is HtmlTestInformation) { |
| 890 enqueueHtmlTest(info, testName, expectations); | 886 enqueueHtmlTest(info, testName, expectations); |
| 891 return; | 887 return; |
| 892 } | 888 } |
| 893 var filePath = info.filePath; | 889 var filePath = info.filePath; |
| 894 var optionsFromFile = info.optionsFromFile; | 890 var optionsFromFile = info.optionsFromFile; |
| 895 | 891 |
| 896 Map buildSpecialPackageRoot(Path pubspecYamlFile) { | 892 Map buildSpecialPackageRoot(Path pubspecYamlFile) { |
| 897 var commands = <Command>[]; | 893 var commands = <Command>[]; |
| 898 var packageDir = pubspecYamlFile.directoryPath; | 894 var packageDir = pubspecYamlFile.directoryPath; |
| 899 var packageName = packageDir.filename; | 895 var packageName = packageDir.filename; |
| 900 | 896 |
| 901 var checkoutDirectory = | 897 var checkoutDirectory = createPubspecCheckoutDirectory(packageDir); |
| 902 createPubspecCheckoutDirectory(packageDir); | |
| 903 var modifiedYamlFile = new Path(checkoutDirectory).append("pubspec.yaml"); | 898 var modifiedYamlFile = new Path(checkoutDirectory).append("pubspec.yaml"); |
| 904 var pubCacheDirectory = new Path(checkoutDirectory).append("pub-cache"); | 899 var pubCacheDirectory = new Path(checkoutDirectory).append("pub-cache"); |
| 905 var newPackageRoot = new Path(checkoutDirectory).append("packages"); | 900 var newPackageRoot = new Path(checkoutDirectory).append("packages"); |
| 906 | 901 |
| 907 // Remove the old packages directory, so we can do a clean 'pub get'. | 902 // Remove the old packages directory, so we can do a clean 'pub get'. |
| 908 var newPackagesDirectory = new Directory(newPackageRoot.toNativePath()); | 903 var newPackagesDirectory = new Directory(newPackageRoot.toNativePath()); |
| 909 if (newPackagesDirectory.existsSync()) { | 904 if (newPackagesDirectory.existsSync()) { |
| 910 newPackagesDirectory.deleteSync(recursive: true); | 905 newPackagesDirectory.deleteSync(recursive: true); |
| 911 } | 906 } |
| 912 | 907 |
| 913 // NOTE: We make a link in the package-root to [packageName], since | 908 // NOTE: We make a link in the package-root to [packageName], since |
| 914 // 'pub get' doesn't create the link to the package containing | 909 // 'pub get' doesn't create the link to the package containing |
| 915 // pubspec.yaml if there is no lib directory. | 910 // pubspec.yaml if there is no lib directory. |
| 916 var packageLink = newPackageRoot.append(packageName); | 911 var packageLink = newPackageRoot.append(packageName); |
| 917 var packageLinkTarget = packageDir.append('lib'); | 912 var packageLinkTarget = packageDir.append('lib'); |
| 918 | 913 |
| 919 // NOTE: We make a link in the package-root to pkg/expect, since | 914 // NOTE: We make a link in the package-root to pkg/expect, since |
| 920 // 'package:expect' is not available on pub.dartlang.org! | 915 // 'package:expect' is not available on pub.dartlang.org! |
| 921 var expectLink = newPackageRoot.append('expect'); | 916 var expectLink = newPackageRoot.append('expect'); |
| 922 var expectLinkTarget = TestUtils.dartDir | 917 var expectLinkTarget = |
| 923 .append('pkg').append('expect').append('lib'); | 918 TestUtils.dartDir.append('pkg').append('expect').append('lib'); |
| 924 | 919 |
| 925 // Generate dependency overrides if we use repository packages. | 920 // Generate dependency overrides if we use repository packages. |
| 926 var packageDirectories = {}; | 921 var packageDirectories = {}; |
| 927 if (configuration['use_repository_packages']) { | 922 if (configuration['use_repository_packages']) { |
| 928 packageDirectories = new Map.from(localPackageDirectories); | 923 packageDirectories = new Map.from(localPackageDirectories); |
| 929 | 924 |
| 930 // Don't create a dependency override for pub, since it's an application | 925 // Don't create a dependency override for pub, since it's an application |
| 931 // package and it has a dependency on compiler_unsupported which isn't | 926 // package and it has a dependency on compiler_unsupported which isn't |
| 932 // in the repo. | 927 // in the repo. |
| 933 packageDirectories.remove('pub'); | 928 packageDirectories.remove('pub'); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 944 destinationFile: modifiedYamlFile.toNativePath())); | 939 destinationFile: modifiedYamlFile.toNativePath())); |
| 945 commands.add(CommandBuilder.instance.getPubCommand( | 940 commands.add(CommandBuilder.instance.getPubCommand( |
| 946 "get", pubPath, checkoutDirectory, pubCacheDirectory.toNativePath())); | 941 "get", pubPath, checkoutDirectory, pubCacheDirectory.toNativePath())); |
| 947 if (new Directory(packageLinkTarget.toNativePath()).existsSync()) { | 942 if (new Directory(packageLinkTarget.toNativePath()).existsSync()) { |
| 948 commands.add(CommandBuilder.instance.getMakeSymlinkCommand( | 943 commands.add(CommandBuilder.instance.getMakeSymlinkCommand( |
| 949 packageLink.toNativePath(), packageLinkTarget.toNativePath())); | 944 packageLink.toNativePath(), packageLinkTarget.toNativePath())); |
| 950 } | 945 } |
| 951 commands.add(CommandBuilder.instance.getMakeSymlinkCommand( | 946 commands.add(CommandBuilder.instance.getMakeSymlinkCommand( |
| 952 expectLink.toNativePath(), expectLinkTarget.toNativePath())); | 947 expectLink.toNativePath(), expectLinkTarget.toNativePath())); |
| 953 | 948 |
| 954 return { | 949 return {'commands': commands, 'package-root': newPackageRoot,}; |
| 955 'commands' : commands, | |
| 956 'package-root' : newPackageRoot, | |
| 957 }; | |
| 958 } | 950 } |
| 959 | 951 |
| 960 // If this test is inside a package, we will check if there is a | 952 // If this test is inside a package, we will check if there is a |
| 961 // pubspec.yaml file and if so, create a custom package root for it. | 953 // pubspec.yaml file and if so, create a custom package root for it. |
| 962 List<Command> baseCommands = <Command>[]; | 954 List<Command> baseCommands = <Command>[]; |
| 963 Path packageRoot; | 955 Path packageRoot; |
| 964 if (configuration['use_repository_packages'] || | 956 if (configuration['use_repository_packages'] || |
| 965 configuration['use_public_packages']) { | 957 configuration['use_public_packages']) { |
| 966 Path pubspecYamlFile = _findPubspecYamlFile(filePath); | 958 Path pubspecYamlFile = _findPubspecYamlFile(filePath); |
| 967 if (pubspecYamlFile != null) { | 959 if (pubspecYamlFile != null) { |
| (...skipping 28 matching lines...) Expand all Loading... |
| 996 multiHtmlTestExpectations[fullTestName] = | 988 multiHtmlTestExpectations[fullTestName] = |
| 997 testExpectations.expectations(fullTestName); | 989 testExpectations.expectations(fullTestName); |
| 998 } | 990 } |
| 999 enqueueBrowserTest(baseCommands, packageRoot, info, testName, | 991 enqueueBrowserTest(baseCommands, packageRoot, info, testName, |
| 1000 multiHtmlTestExpectations); | 992 multiHtmlTestExpectations); |
| 1001 } else { | 993 } else { |
| 1002 enqueueBrowserTest( | 994 enqueueBrowserTest( |
| 1003 baseCommands, packageRoot, info, testName, expectations); | 995 baseCommands, packageRoot, info, testName, expectations); |
| 1004 } | 996 } |
| 1005 } else { | 997 } else { |
| 1006 enqueueStandardTest( | 998 enqueueStandardTest(baseCommands, info, testName, expectations); |
| 1007 baseCommands, info, testName, expectations); | |
| 1008 } | 999 } |
| 1009 } | 1000 } |
| 1010 | 1001 |
| 1011 void enqueueStandardTest(List<Command> baseCommands, | 1002 void enqueueStandardTest(List<Command> baseCommands, TestInformation info, |
| 1012 TestInformation info, | 1003 String testName, Set<Expectation> expectations) { |
| 1013 String testName, | 1004 var commonArguments = |
| 1014 Set<Expectation> expectations) { | 1005 commonArgumentsFromFile(info.filePath, info.optionsFromFile); |
| 1015 var commonArguments = commonArgumentsFromFile(info.filePath, | |
| 1016 info.optionsFromFile); | |
| 1017 | 1006 |
| 1018 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); | 1007 List<List<String>> vmOptionsList = getVmOptions(info.optionsFromFile); |
| 1019 assert(!vmOptionsList.isEmpty); | 1008 assert(!vmOptionsList.isEmpty); |
| 1020 | 1009 |
| 1021 for (var vmOptionsVarient = 0; | 1010 for (var vmOptionsVarient = 0; |
| 1022 vmOptionsVarient < vmOptionsList.length; | 1011 vmOptionsVarient < vmOptionsList.length; |
| 1023 vmOptionsVarient++) { | 1012 vmOptionsVarient++) { |
| 1024 var vmOptions = vmOptionsList[vmOptionsVarient]; | 1013 var vmOptions = vmOptionsList[vmOptionsVarient]; |
| 1025 var allVmOptions = vmOptions; | 1014 var allVmOptions = vmOptions; |
| 1026 if (!extraVmOptions.isEmpty) { | 1015 if (!extraVmOptions.isEmpty) { |
| 1027 allVmOptions = new List.from(vmOptions)..addAll(extraVmOptions); | 1016 allVmOptions = new List.from(vmOptions)..addAll(extraVmOptions); |
| 1028 } | 1017 } |
| 1029 | 1018 |
| 1030 var commands = []..addAll(baseCommands); | 1019 var commands = []..addAll(baseCommands); |
| 1031 commands.addAll(makeCommands(info, vmOptionsVarient, | 1020 commands.addAll( |
| 1032 allVmOptions, commonArguments)); | 1021 makeCommands(info, vmOptionsVarient, allVmOptions, commonArguments)); |
| 1033 enqueueNewTestCase( | 1022 enqueueNewTestCase(new TestCase( |
| 1034 new TestCase('$suiteName/$testName', | 1023 '$suiteName/$testName', commands, configuration, expectations, |
| 1035 commands, | 1024 isNegative: isNegative(info), info: info)); |
| 1036 configuration, | |
| 1037 expectations, | |
| 1038 isNegative: isNegative(info), | |
| 1039 info: info)); | |
| 1040 } | 1025 } |
| 1041 } | 1026 } |
| 1042 | 1027 |
| 1043 bool expectCompileError(TestInformation info) { | 1028 bool expectCompileError(TestInformation info) { |
| 1044 return info.hasCompileError || | 1029 return info.hasCompileError || |
| 1045 (configuration['checked'] && info.hasCompileErrorIfChecked); | 1030 (configuration['checked'] && info.hasCompileErrorIfChecked); |
| 1046 } | 1031 } |
| 1047 | 1032 |
| 1048 bool isNegative(TestInformation info) { | 1033 bool isNegative(TestInformation info) { |
| 1049 bool negative = expectCompileError(info) || | 1034 bool negative = expectCompileError(info) || |
| 1050 (configuration['checked'] && info.isNegativeIfChecked); | 1035 (configuration['checked'] && info.isNegativeIfChecked); |
| 1051 if (info.hasRuntimeError && hasRuntime) { | 1036 if (info.hasRuntimeError && hasRuntime) { |
| 1052 negative = true; | 1037 negative = true; |
| 1053 } | 1038 } |
| 1054 return negative; | 1039 return negative; |
| 1055 } | 1040 } |
| 1056 | 1041 |
| 1057 List<Command> makeCommands(TestInformation info, | 1042 List<Command> makeCommands( |
| 1058 int vmOptionsVarient, | 1043 TestInformation info, int vmOptionsVarient, var vmOptions, var args) { |
| 1059 var vmOptions, | |
| 1060 var args) { | |
| 1061 List<Command> commands = <Command>[]; | 1044 List<Command> commands = <Command>[]; |
| 1062 CompilerConfiguration compilerConfiguration = | 1045 CompilerConfiguration compilerConfiguration = |
| 1063 new CompilerConfiguration(configuration); | 1046 new CompilerConfiguration(configuration); |
| 1064 List<String> sharedOptions = info.optionsFromFile['sharedOptions']; | 1047 List<String> sharedOptions = info.optionsFromFile['sharedOptions']; |
| 1065 | 1048 |
| 1066 List<String> compileTimeArguments = <String>[]; | 1049 List<String> compileTimeArguments = <String>[]; |
| 1067 String tempDir; | 1050 String tempDir; |
| 1068 if (compilerConfiguration.hasCompiler) { | 1051 if (compilerConfiguration.hasCompiler) { |
| 1069 compileTimeArguments = | 1052 compileTimeArguments = compilerConfiguration.computeCompilerArguments( |
| 1070 compilerConfiguration.computeCompilerArguments(vmOptions, | 1053 vmOptions, sharedOptions, args); |
| 1071 sharedOptions, | |
| 1072 args); | |
| 1073 // Avoid doing this for analyzer. | 1054 // Avoid doing this for analyzer. |
| 1074 var path = info.filePath; | 1055 var path = info.filePath; |
| 1075 if (vmOptionsVarient != 0) { | 1056 if (vmOptionsVarient != 0) { |
| 1076 // Ensure a unique directory for each test case. | 1057 // Ensure a unique directory for each test case. |
| 1077 path = path.join(new Path(vmOptionsVarient.toString())); | 1058 path = path.join(new Path(vmOptionsVarient.toString())); |
| 1078 } | 1059 } |
| 1079 tempDir = createCompilationOutputDirectory(path); | 1060 tempDir = createCompilationOutputDirectory(path); |
| 1080 } | 1061 } |
| 1081 | 1062 |
| 1082 CommandArtifact compilationArtifact = | 1063 CommandArtifact compilationArtifact = |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1094 return commands; | 1075 return commands; |
| 1095 } | 1076 } |
| 1096 | 1077 |
| 1097 RuntimeConfiguration runtimeConfiguration = | 1078 RuntimeConfiguration runtimeConfiguration = |
| 1098 new RuntimeConfiguration(configuration); | 1079 new RuntimeConfiguration(configuration); |
| 1099 List<String> runtimeArguments = | 1080 List<String> runtimeArguments = |
| 1100 compilerConfiguration.computeRuntimeArguments( | 1081 compilerConfiguration.computeRuntimeArguments( |
| 1101 runtimeConfiguration, | 1082 runtimeConfiguration, |
| 1102 buildDir, | 1083 buildDir, |
| 1103 info, | 1084 info, |
| 1104 vmOptions, sharedOptions, args, | 1085 vmOptions, |
| 1086 sharedOptions, |
| 1087 args, |
| 1105 compilationArtifact); | 1088 compilationArtifact); |
| 1106 | 1089 |
| 1107 return commands | 1090 return commands |
| 1108 ..addAll( | 1091 ..addAll(runtimeConfiguration.computeRuntimeCommands( |
| 1109 runtimeConfiguration.computeRuntimeCommands( | 1092 this, |
| 1110 this, | 1093 CommandBuilder.instance, |
| 1111 CommandBuilder.instance, | 1094 compilationArtifact, |
| 1112 compilationArtifact, | 1095 runtimeArguments, |
| 1113 runtimeArguments, | 1096 environmentOverrides)); |
| 1114 environmentOverrides)); | |
| 1115 } | 1097 } |
| 1116 | 1098 |
| 1117 CreateTest makeTestCaseCreator(Map optionsFromFile) { | 1099 CreateTest makeTestCaseCreator(Map optionsFromFile) { |
| 1118 return (Path filePath, | 1100 return (Path filePath, Path originTestPath, bool hasCompileError, |
| 1119 Path originTestPath, | 1101 bool hasRuntimeError, |
| 1120 bool hasCompileError, | 1102 {bool isNegativeIfChecked: false, |
| 1121 bool hasRuntimeError, | 1103 bool hasCompileErrorIfChecked: false, |
| 1122 {bool isNegativeIfChecked: false, | 1104 bool hasStaticWarning: false, |
| 1123 bool hasCompileErrorIfChecked: false, | 1105 String multitestKey}) { |
| 1124 bool hasStaticWarning: false, | |
| 1125 String multitestKey}) { | |
| 1126 // Cache the test information for each test case. | 1106 // Cache the test information for each test case. |
| 1127 var info = new TestInformation(filePath, | 1107 var info = new TestInformation( |
| 1128 originTestPath, | 1108 filePath, |
| 1129 optionsFromFile, | 1109 originTestPath, |
| 1130 hasCompileError, | 1110 optionsFromFile, |
| 1131 hasRuntimeError, | 1111 hasCompileError, |
| 1132 isNegativeIfChecked, | 1112 hasRuntimeError, |
| 1133 hasCompileErrorIfChecked, | 1113 isNegativeIfChecked, |
| 1134 hasStaticWarning, | 1114 hasCompileErrorIfChecked, |
| 1135 multitestKey: multitestKey); | 1115 hasStaticWarning, |
| 1116 multitestKey: multitestKey); |
| 1136 cachedTests.add(info); | 1117 cachedTests.add(info); |
| 1137 enqueueTestCaseFromTestInformation(info); | 1118 enqueueTestCaseFromTestInformation(info); |
| 1138 }; | 1119 }; |
| 1139 } | 1120 } |
| 1140 | 1121 |
| 1141 /** | 1122 /** |
| 1142 * _createUrlPathFromFile takes a [file], which is either located in the dart | 1123 * _createUrlPathFromFile takes a [file], which is either located in the dart |
| 1143 * or in the build directory, and will return a String representing | 1124 * or in the build directory, and will return a String representing |
| 1144 * the relative path to either the dart or the build directory. | 1125 * the relative path to either the dart or the build directory. |
| 1145 * Thus, the returned [String] will be the path component of the URL | 1126 * Thus, the returned [String] will be the path component of the URL |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1172 if (configuration['list']) { | 1153 if (configuration['list']) { |
| 1173 return Uri.parse('http://listing_the_tests_only'); | 1154 return Uri.parse('http://listing_the_tests_only'); |
| 1174 } | 1155 } |
| 1175 assert(configuration.containsKey('_servers_')); | 1156 assert(configuration.containsKey('_servers_')); |
| 1176 int serverPort = configuration['_servers_'].port; | 1157 int serverPort = configuration['_servers_'].port; |
| 1177 int crossOriginPort = configuration['_servers_'].crossOriginPort; | 1158 int crossOriginPort = configuration['_servers_'].crossOriginPort; |
| 1178 Map parameters = {'crossOriginPort': crossOriginPort.toString()}; | 1159 Map parameters = {'crossOriginPort': crossOriginPort.toString()}; |
| 1179 if (subtestName != null) { | 1160 if (subtestName != null) { |
| 1180 parameters['group'] = subtestName; | 1161 parameters['group'] = subtestName; |
| 1181 } | 1162 } |
| 1182 return new Uri(scheme: 'http', | 1163 return new Uri( |
| 1183 host: configuration['local_ip'], | 1164 scheme: 'http', |
| 1184 port: serverPort, | 1165 host: configuration['local_ip'], |
| 1185 path: pathComponent, | 1166 port: serverPort, |
| 1186 queryParameters: parameters); | 1167 path: pathComponent, |
| 1168 queryParameters: parameters); |
| 1187 } | 1169 } |
| 1188 | 1170 |
| 1189 void _createWrapperFile(String dartWrapperFilename, | 1171 void _createWrapperFile( |
| 1190 Path localDartLibraryFilename) { | 1172 String dartWrapperFilename, Path localDartLibraryFilename) { |
| 1191 File file = new File(dartWrapperFilename); | 1173 File file = new File(dartWrapperFilename); |
| 1192 RandomAccessFile dartWrapper = file.openSync(mode: FileMode.WRITE); | 1174 RandomAccessFile dartWrapper = file.openSync(mode: FileMode.WRITE); |
| 1193 | 1175 |
| 1194 var libraryPathComponent = _createUrlPathFromFile(localDartLibraryFilename); | 1176 var libraryPathComponent = _createUrlPathFromFile(localDartLibraryFilename); |
| 1195 var generatedSource = dartTestWrapper(libraryPathComponent); | 1177 var generatedSource = dartTestWrapper(libraryPathComponent); |
| 1196 dartWrapper.writeStringSync(generatedSource); | 1178 dartWrapper.writeStringSync(generatedSource); |
| 1197 dartWrapper.closeSync(); | 1179 dartWrapper.closeSync(); |
| 1198 } | 1180 } |
| 1199 | 1181 |
| 1200 /** | 1182 /** |
| 1201 * The [StandardTestSuite] has support for tests that | 1183 * The [StandardTestSuite] has support for tests that |
| 1202 * compile a test from Dart to JavaScript, and then run the resulting | 1184 * compile a test from Dart to JavaScript, and then run the resulting |
| 1203 * JavaScript. This function creates a working directory to hold the | 1185 * JavaScript. This function creates a working directory to hold the |
| 1204 * JavaScript version of the test, and copies the appropriate framework | 1186 * JavaScript version of the test, and copies the appropriate framework |
| 1205 * files to that directory. It creates a [BrowserTestCase], which has | 1187 * files to that directory. It creates a [BrowserTestCase], which has |
| 1206 * two sequential steps to be run by the [ProcessQueue] when the test is | 1188 * two sequential steps to be run by the [ProcessQueue] when the test is |
| 1207 * executed: a compilation step and an execution step, both with the | 1189 * executed: a compilation step and an execution step, both with the |
| 1208 * appropriate executable and arguments. The [expectations] object can be | 1190 * appropriate executable and arguments. The [expectations] object can be |
| 1209 * either a Set<String> if the test is a regular test, or a Map<String | 1191 * either a Set<String> if the test is a regular test, or a Map<String |
| 1210 * subTestName, Set<String>> if we are running a browser multi-test (one | 1192 * subTestName, Set<String>> if we are running a browser multi-test (one |
| 1211 * compilation and many browser runs). | 1193 * compilation and many browser runs). |
| 1212 */ | 1194 */ |
| 1213 void enqueueBrowserTest( | 1195 void enqueueBrowserTest(List<Command> baseCommands, Path packageRoot, |
| 1214 List<Command> baseCommands, | 1196 TestInformation info, String testName, expectations) { |
| 1215 Path packageRoot, | |
| 1216 TestInformation info, | |
| 1217 String testName, | |
| 1218 expectations) { | |
| 1219 RegExp badChars = new RegExp('[-=/]'); | 1197 RegExp badChars = new RegExp('[-=/]'); |
| 1220 List VmOptionsList = getVmOptions(info.optionsFromFile); | 1198 List VmOptionsList = getVmOptions(info.optionsFromFile); |
| 1221 bool multipleOptions = VmOptionsList.length > 1; | 1199 bool multipleOptions = VmOptionsList.length > 1; |
| 1222 for (var vmOptions in VmOptionsList) { | 1200 for (var vmOptions in VmOptionsList) { |
| 1223 String optionsName = | 1201 String optionsName = |
| 1224 multipleOptions ? vmOptions.join('-').replaceAll(badChars, '') : ''; | 1202 multipleOptions ? vmOptions.join('-').replaceAll(badChars, '') : ''; |
| 1225 String tempDir = createOutputDirectory(info.filePath, optionsName); | 1203 String tempDir = createOutputDirectory(info.filePath, optionsName); |
| 1226 enqueueBrowserTestWithOptions( | 1204 enqueueBrowserTestWithOptions(baseCommands, packageRoot, info, testName, |
| 1227 baseCommands, | 1205 expectations, vmOptions, tempDir); |
| 1228 packageRoot, | |
| 1229 info, | |
| 1230 testName, | |
| 1231 expectations, | |
| 1232 vmOptions, | |
| 1233 tempDir); | |
| 1234 } | 1206 } |
| 1235 } | 1207 } |
| 1236 | 1208 |
| 1237 | |
| 1238 void enqueueBrowserTestWithOptions( | 1209 void enqueueBrowserTestWithOptions( |
| 1239 List<Command> baseCommands, | 1210 List<Command> baseCommands, |
| 1240 Path packageRoot, | 1211 Path packageRoot, |
| 1241 TestInformation info, | 1212 TestInformation info, |
| 1242 String testName, | 1213 String testName, |
| 1243 expectations, | 1214 expectations, |
| 1244 List<String> vmOptions, | 1215 List<String> vmOptions, |
| 1245 String tempDir) { | 1216 String tempDir) { |
| 1246 // TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot] | 1217 // TODO(Issue 14651): If we're on dartium, we need to pass [packageRoot] |
| 1247 // on to the browser (it may be test specific). | 1218 // on to the browser (it may be test specific). |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1330 scriptPath = compiledDartWrapperFilename; | 1301 scriptPath = compiledDartWrapperFilename; |
| 1331 } | 1302 } |
| 1332 scriptPath = _createUrlPathFromFile(new Path(scriptPath)); | 1303 scriptPath = _createUrlPathFromFile(new Path(scriptPath)); |
| 1333 | 1304 |
| 1334 content = getHtmlContents(filename, scriptType, new Path("$scriptPath")); | 1305 content = getHtmlContents(filename, scriptType, new Path("$scriptPath")); |
| 1335 htmlTest.writeStringSync(content); | 1306 htmlTest.writeStringSync(content); |
| 1336 htmlTest.closeSync(); | 1307 htmlTest.closeSync(); |
| 1337 } | 1308 } |
| 1338 | 1309 |
| 1339 if (compiler != 'none') { | 1310 if (compiler != 'none') { |
| 1340 commands.add( | 1311 commands.add(_compileCommand(dartWrapperFilename, |
| 1341 _compileCommand( | 1312 compiledDartWrapperFilename, compiler, tempDir, optionsFromFile)); |
| 1342 dartWrapperFilename, | |
| 1343 compiledDartWrapperFilename, | |
| 1344 compiler, | |
| 1345 tempDir, | |
| 1346 optionsFromFile)); | |
| 1347 } | 1313 } |
| 1348 | 1314 |
| 1349 // some tests require compiling multiple input scripts. | 1315 // some tests require compiling multiple input scripts. |
| 1350 List<String> otherScripts = optionsFromFile['otherScripts']; | 1316 List<String> otherScripts = optionsFromFile['otherScripts']; |
| 1351 for (String name in otherScripts) { | 1317 for (String name in otherScripts) { |
| 1352 Path namePath = new Path(name); | 1318 Path namePath = new Path(name); |
| 1353 String fileName = namePath.filename; | 1319 String fileName = namePath.filename; |
| 1354 Path fromPath = filePath.directoryPath.join(namePath); | 1320 Path fromPath = filePath.directoryPath.join(namePath); |
| 1355 if (compiler != 'none') { | 1321 if (compiler != 'none') { |
| 1356 assert(namePath.extension == 'dart'); | 1322 assert(namePath.extension == 'dart'); |
| 1357 commands.add( | 1323 commands.add(_compileCommand(fromPath.toNativePath(), |
| 1358 _compileCommand( | 1324 '$tempDir/$fileName.js', compiler, tempDir, optionsFromFile)); |
| 1359 fromPath.toNativePath(), | |
| 1360 '$tempDir/$fileName.js', | |
| 1361 compiler, | |
| 1362 tempDir, | |
| 1363 optionsFromFile)); | |
| 1364 } | 1325 } |
| 1365 if (compiler == 'none') { | 1326 if (compiler == 'none') { |
| 1366 // For the tests that require multiple input scripts but are not | 1327 // For the tests that require multiple input scripts but are not |
| 1367 // compiled, move the input scripts over with the script so they can | 1328 // compiled, move the input scripts over with the script so they can |
| 1368 // be accessed. | 1329 // be accessed. |
| 1369 String result = new File(fromPath.toNativePath()).readAsStringSync(); | 1330 String result = new File(fromPath.toNativePath()).readAsStringSync(); |
| 1370 new File('$tempDir/$fileName').writeAsStringSync(result); | 1331 new File('$tempDir/$fileName').writeAsStringSync(result); |
| 1371 } | 1332 } |
| 1372 } | 1333 } |
| 1373 | 1334 |
| 1374 | |
| 1375 // Variables for browser multi-tests. | 1335 // Variables for browser multi-tests. |
| 1376 bool multitest = info.optionsFromFile['isMultiHtmlTest']; | 1336 bool multitest = info.optionsFromFile['isMultiHtmlTest']; |
| 1377 List<String> subtestNames = | 1337 List<String> subtestNames = |
| 1378 multitest ? info.optionsFromFile['subtestNames'] : [null]; | 1338 multitest ? info.optionsFromFile['subtestNames'] : [null]; |
| 1379 for (String subtestName in subtestNames) { | 1339 for (String subtestName in subtestNames) { |
| 1380 // Construct the command that executes the browser test | 1340 // Construct the command that executes the browser test |
| 1381 List<Command> commandSet = new List<Command>.from(commands); | 1341 List<Command> commandSet = new List<Command>.from(commands); |
| 1382 | 1342 |
| 1383 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath)); | 1343 var htmlPath_subtest = _createUrlPathFromFile(new Path(htmlPath)); |
| 1384 var fullHtmlPath = | 1344 var fullHtmlPath = |
| 1385 _getUriForBrowserTest(htmlPath_subtest, subtestName).toString(); | 1345 _getUriForBrowserTest(htmlPath_subtest, subtestName).toString(); |
| 1386 | 1346 |
| 1387 if (runtime == "drt") { | 1347 if (runtime == "drt") { |
| 1388 var dartFlags = []; | 1348 var dartFlags = []; |
| 1389 var contentShellOptions = []; | 1349 var contentShellOptions = []; |
| 1390 | 1350 |
| 1391 contentShellOptions.add('--no-timeout'); | 1351 contentShellOptions.add('--no-timeout'); |
| 1392 contentShellOptions.add('--dump-render-tree'); | 1352 contentShellOptions.add('--dump-render-tree'); |
| 1393 | 1353 |
| 1394 if (compiler == 'none') { | 1354 if (compiler == 'none') { |
| 1395 dartFlags.add('--ignore-unrecognized-flags'); | 1355 dartFlags.add('--ignore-unrecognized-flags'); |
| 1396 if (configuration["checked"]) { | 1356 if (configuration["checked"]) { |
| 1397 dartFlags.add('--enable_asserts'); | 1357 dartFlags.add('--enable_asserts'); |
| 1398 dartFlags.add("--enable_type_checks"); | 1358 dartFlags.add("--enable_type_checks"); |
| 1399 } | 1359 } |
| 1400 dartFlags.addAll(vmOptions); | 1360 dartFlags.addAll(vmOptions); |
| 1401 } | 1361 } |
| 1402 | 1362 |
| 1403 commandSet.add( | 1363 commandSet.add(CommandBuilder.instance.getContentShellCommand( |
| 1404 CommandBuilder.instance.getContentShellCommand( | 1364 contentShellFilename, |
| 1405 contentShellFilename, | 1365 fullHtmlPath, |
| 1406 fullHtmlPath, | 1366 contentShellOptions, |
| 1407 contentShellOptions, | 1367 dartFlags, |
| 1408 dartFlags, | 1368 environmentOverrides)); |
| 1409 environmentOverrides)); | |
| 1410 } else { | 1369 } else { |
| 1411 commandSet.add( | 1370 commandSet.add(CommandBuilder.instance.getBrowserTestCommand( |
| 1412 CommandBuilder.instance.getBrowserTestCommand( | 1371 runtime, fullHtmlPath, configuration, !isNegative(info))); |
| 1413 runtime, | |
| 1414 fullHtmlPath, | |
| 1415 configuration, | |
| 1416 !isNegative(info))); | |
| 1417 } | 1372 } |
| 1418 | 1373 |
| 1419 // Create BrowserTestCase and queue it. | 1374 // Create BrowserTestCase and queue it. |
| 1420 var fullTestName = multitest ? '$testName/$subtestName' : testName; | 1375 var fullTestName = multitest ? '$testName/$subtestName' : testName; |
| 1421 var expectation = multitest ? expectations[fullTestName] : expectations; | 1376 var expectation = multitest ? expectations[fullTestName] : expectations; |
| 1422 var testCase = new BrowserTestCase( | 1377 var testCase = new BrowserTestCase('$suiteName/$fullTestName', commandSet, |
| 1423 '$suiteName/$fullTestName', | 1378 configuration, expectation, info, isNegative(info), fullHtmlPath); |
| 1424 commandSet, | |
| 1425 configuration, | |
| 1426 expectation, | |
| 1427 info, | |
| 1428 isNegative(info), | |
| 1429 fullHtmlPath); | |
| 1430 | 1379 |
| 1431 enqueueNewTestCase(testCase); | 1380 enqueueNewTestCase(testCase); |
| 1432 } | 1381 } |
| 1433 } | 1382 } |
| 1434 | 1383 |
| 1435 void enqueueHtmlTest( | 1384 void enqueueHtmlTest( |
| 1436 HtmlTestInformation info, | 1385 HtmlTestInformation info, String testName, expectations) { |
| 1437 String testName, | |
| 1438 expectations) { | |
| 1439 final String compiler = configuration['compiler']; | 1386 final String compiler = configuration['compiler']; |
| 1440 final String runtime = configuration['runtime']; | 1387 final String runtime = configuration['runtime']; |
| 1441 // Html tests work only with the browser controller. | 1388 // Html tests work only with the browser controller. |
| 1442 if (!TestUtils.isBrowserRuntime(runtime) || runtime == 'drt') { | 1389 if (!TestUtils.isBrowserRuntime(runtime) || runtime == 'drt') { |
| 1443 return; | 1390 return; |
| 1444 } | 1391 } |
| 1445 bool compileToJS = (compiler == 'dart2js'); | 1392 bool compileToJS = (compiler == 'dart2js'); |
| 1446 | 1393 |
| 1447 final Path filePath = info.filePath; | 1394 final Path filePath = info.filePath; |
| 1448 final String tempDir = createOutputDirectory(filePath, ''); | 1395 final String tempDir = createOutputDirectory(filePath, ''); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1468 Fail('HTML test scripts must have relative paths: $scriptPath'); | 1415 Fail('HTML test scripts must have relative paths: $scriptPath'); |
| 1469 break; | 1416 break; |
| 1470 } | 1417 } |
| 1471 if (uri.pathSegments.length > 1) { | 1418 if (uri.pathSegments.length > 1) { |
| 1472 Fail('HTML test scripts must be in test directory: $scriptPath'); | 1419 Fail('HTML test scripts must be in test directory: $scriptPath'); |
| 1473 break; | 1420 break; |
| 1474 } | 1421 } |
| 1475 Uri script = testUri.resolveUri(uri); | 1422 Uri script = testUri.resolveUri(uri); |
| 1476 Uri copiedScript = tempUri.resolveUri(uri); | 1423 Uri copiedScript = tempUri.resolveUri(uri); |
| 1477 if (compiler == 'none' || scriptPath.endsWith('.js')) { | 1424 if (compiler == 'none' || scriptPath.endsWith('.js')) { |
| 1478 new File.fromUri(copiedScript).writeAsStringSync( | 1425 new File.fromUri(copiedScript) |
| 1479 new File.fromUri(script).readAsStringSync()); | 1426 .writeAsStringSync(new File.fromUri(script).readAsStringSync()); |
| 1480 } else { | 1427 } else { |
| 1481 var destination = copiedScript.toFilePath(); | 1428 var destination = copiedScript.toFilePath(); |
| 1482 if (compileToJS) { | 1429 if (compileToJS) { |
| 1483 destination = destination.replaceFirst(dartExtension, '.js'); | 1430 destination = destination.replaceFirst(dartExtension, '.js'); |
| 1484 } | 1431 } |
| 1485 commands.add(_compileCommand( | 1432 commands.add(_compileCommand(script.toFilePath(), destination, |
| 1486 script.toFilePath(), | 1433 compiler, tempDir, info.optionsFromFile)); |
| 1487 destination, | |
| 1488 compiler, | |
| 1489 tempDir, | |
| 1490 info.optionsFromFile)); | |
| 1491 } | 1434 } |
| 1492 } | 1435 } |
| 1493 } | 1436 } |
| 1494 final Uri htmlFile = tempUri.resolve(filePath.filename); | 1437 final Uri htmlFile = tempUri.resolve(filePath.filename); |
| 1495 new File.fromUri(htmlFile).writeAsStringSync(contents); | 1438 new File.fromUri(htmlFile).writeAsStringSync(contents); |
| 1496 | 1439 |
| 1497 var htmlPath = _createUrlPathFromFile(new Path(htmlFile.toFilePath())); | 1440 var htmlPath = _createUrlPathFromFile(new Path(htmlFile.toFilePath())); |
| 1498 var fullHtmlPath = _getUriForBrowserTest(htmlPath, null).toString(); | 1441 var fullHtmlPath = _getUriForBrowserTest(htmlPath, null).toString(); |
| 1499 commands.add(CommandBuilder.instance.getBrowserHtmlTestCommand( | 1442 commands.add(CommandBuilder.instance.getBrowserHtmlTestCommand(runtime, |
| 1500 runtime, | 1443 fullHtmlPath, configuration, info.expectedMessages, !isNegative(info))); |
| 1501 fullHtmlPath, | |
| 1502 configuration, | |
| 1503 info.expectedMessages, | |
| 1504 !isNegative(info))); | |
| 1505 String testDisplayName = '$suiteName/$testName'; | 1444 String testDisplayName = '$suiteName/$testName'; |
| 1506 var testCase = new BrowserTestCase( | 1445 var testCase = new BrowserTestCase(testDisplayName, commands, configuration, |
| 1507 testDisplayName, | 1446 expectations, info, isNegative(info), fullHtmlPath); |
| 1508 commands, | |
| 1509 configuration, | |
| 1510 expectations, | |
| 1511 info, | |
| 1512 isNegative(info), | |
| 1513 fullHtmlPath); | |
| 1514 enqueueNewTestCase(testCase); | 1447 enqueueNewTestCase(testCase); |
| 1515 return; | 1448 return; |
| 1516 } | 1449 } |
| 1517 | 1450 |
| 1518 /** Helper to create a compilation command for a single input file. */ | 1451 /** Helper to create a compilation command for a single input file. */ |
| 1519 Command _compileCommand(String inputFile, String outputFile, | 1452 Command _compileCommand(String inputFile, String outputFile, String compiler, |
| 1520 String compiler, String dir, optionsFromFile) { | 1453 String dir, optionsFromFile) { |
| 1521 assert(compiler == 'dart2js'); | 1454 assert(compiler == 'dart2js'); |
| 1522 List<String> args; | 1455 List<String> args; |
| 1523 if (compilerPath.endsWith('.dart')) { | 1456 if (compilerPath.endsWith('.dart')) { |
| 1524 // Run the compiler script via the Dart VM. | 1457 // Run the compiler script via the Dart VM. |
| 1525 args = [compilerPath]; | 1458 args = [compilerPath]; |
| 1526 } else { | 1459 } else { |
| 1527 args = []; | 1460 args = []; |
| 1528 } | 1461 } |
| 1529 args.addAll(TestUtils.standardOptions(configuration)); | 1462 args.addAll(TestUtils.standardOptions(configuration)); |
| 1530 String packageRoot = | 1463 String packageRoot = packageRootArgument(optionsFromFile['packageRoot']); |
| 1531 packageRootArgument(optionsFromFile['packageRoot']); | |
| 1532 if (packageRoot != null) args.add(packageRoot); | 1464 if (packageRoot != null) args.add(packageRoot); |
| 1533 String packages = packagesArgument(optionsFromFile['packages']); | 1465 String packages = packagesArgument(optionsFromFile['packages']); |
| 1534 if (packages != null) args.add(packages); | 1466 if (packages != null) args.add(packages); |
| 1535 args.add('--out=$outputFile'); | 1467 args.add('--out=$outputFile'); |
| 1536 args.add(inputFile); | 1468 args.add(inputFile); |
| 1537 List<String> options = optionsFromFile['sharedOptions']; | 1469 List<String> options = optionsFromFile['sharedOptions']; |
| 1538 if (options != null) args.addAll(options); | 1470 if (options != null) args.addAll(options); |
| 1539 return CommandBuilder.instance.getCompilationCommand( | 1471 return CommandBuilder.instance.getCompilationCommand( |
| 1540 compiler, outputFile, !useSdk, | 1472 compiler, |
| 1541 dart2JsBootstrapDependencies, compilerPath, args, environmentOverrides); | 1473 outputFile, |
| 1474 !useSdk, |
| 1475 dart2JsBootstrapDependencies, |
| 1476 compilerPath, |
| 1477 args, |
| 1478 environmentOverrides); |
| 1542 } | 1479 } |
| 1543 | 1480 |
| 1544 /** Helper to create a Polymer deploy command for a single HTML file. */ | 1481 /** Helper to create a Polymer deploy command for a single HTML file. */ |
| 1545 Command _polymerDeployCommand(String inputFile, String outputDir, | 1482 Command _polymerDeployCommand( |
| 1546 optionsFromFile) { | 1483 String inputFile, String outputDir, optionsFromFile) { |
| 1547 List<String> args = []; | 1484 List<String> args = []; |
| 1548 String packageRoot = packageRootArgument(optionsFromFile['packageRoot']); | 1485 String packageRoot = packageRootArgument(optionsFromFile['packageRoot']); |
| 1549 if (packageRoot != null) args.add(packageRoot); | 1486 if (packageRoot != null) args.add(packageRoot); |
| 1550 String packages = packagesArgument(optionsFromFile['packages']); | 1487 String packages = packagesArgument(optionsFromFile['packages']); |
| 1551 if (packages != null) args.add(packages); | 1488 if (packages != null) args.add(packages); |
| 1552 args..add('package:polymer/deploy.dart') | 1489 args |
| 1553 ..add('--test')..add(inputFile) | 1490 ..add('package:polymer/deploy.dart') |
| 1554 ..add('--out')..add(outputDir) | 1491 ..add('--test') |
| 1555 ..add('--file-filter')..add('.svn'); | 1492 ..add(inputFile) |
| 1493 ..add('--out') |
| 1494 ..add(outputDir) |
| 1495 ..add('--file-filter') |
| 1496 ..add('.svn'); |
| 1556 if (configuration['csp']) args.add('--csp'); | 1497 if (configuration['csp']) args.add('--csp'); |
| 1557 | 1498 |
| 1558 return CommandBuilder.instance.getProcessCommand( | 1499 return CommandBuilder.instance.getProcessCommand( |
| 1559 'polymer_deploy', dartVmBinaryFileName, args, environmentOverrides); | 1500 'polymer_deploy', dartVmBinaryFileName, args, environmentOverrides); |
| 1560 } | 1501 } |
| 1561 | 1502 |
| 1562 String get scriptType { | 1503 String get scriptType { |
| 1563 switch (configuration['compiler']) { | 1504 switch (configuration['compiler']) { |
| 1564 case 'none': | 1505 case 'none': |
| 1565 return 'application/dart'; | 1506 return 'application/dart'; |
| 1566 case 'dart2js': | 1507 case 'dart2js': |
| 1567 case 'dart2analyzer': | 1508 case 'dart2analyzer': |
| 1568 return 'text/javascript'; | 1509 return 'text/javascript'; |
| 1569 default: | 1510 default: |
| 1570 print('Non-web runtime, so no scriptType for: ' | 1511 print('Non-web runtime, so no scriptType for: ' |
| 1571 '${configuration["compiler"]}'); | 1512 '${configuration["compiler"]}'); |
| 1572 exit(1); | 1513 exit(1); |
| 1573 return null; | 1514 return null; |
| 1574 } | 1515 } |
| 1575 } | 1516 } |
| 1576 | 1517 |
| 1577 bool get hasRuntime { | 1518 bool get hasRuntime { |
| 1578 switch(configuration['runtime']) { | 1519 switch (configuration['runtime']) { |
| 1579 case 'none': | 1520 case 'none': |
| 1580 return false; | 1521 return false; |
| 1581 default: | 1522 default: |
| 1582 return true; | 1523 return true; |
| 1583 } | 1524 } |
| 1584 } | 1525 } |
| 1585 | 1526 |
| 1586 String get contentShellFilename { | 1527 String get contentShellFilename { |
| 1587 if (configuration['drt'] != '') { | 1528 if (configuration['drt'] != '') { |
| 1588 return configuration['drt']; | 1529 return configuration['drt']; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1607 args.add(packages); | 1548 args.add(packages); |
| 1608 } | 1549 } |
| 1609 args.addAll(additionalOptions(filePath)); | 1550 args.addAll(additionalOptions(filePath)); |
| 1610 if (configuration['analyzer']) { | 1551 if (configuration['analyzer']) { |
| 1611 args.add('--machine'); | 1552 args.add('--machine'); |
| 1612 args.add('--no-hints'); | 1553 args.add('--no-hints'); |
| 1613 } | 1554 } |
| 1614 | 1555 |
| 1615 if (configuration["compiler"] == "dart2analyzer" && | 1556 if (configuration["compiler"] == "dart2analyzer" && |
| 1616 (filePath.filename.contains("dart2js") || | 1557 (filePath.filename.contains("dart2js") || |
| 1617 filePath.directoryPath.segments().last.contains('html_common'))) { | 1558 filePath.directoryPath.segments().last.contains('html_common'))) { |
| 1618 args.add("--use-dart2js-libraries"); | 1559 args.add("--use-dart2js-libraries"); |
| 1619 } | 1560 } |
| 1620 | 1561 |
| 1621 bool isMultitest = optionsFromFile["isMultitest"]; | 1562 bool isMultitest = optionsFromFile["isMultitest"]; |
| 1622 List<String> dartOptions = optionsFromFile["dartOptions"]; | 1563 List<String> dartOptions = optionsFromFile["dartOptions"]; |
| 1623 | 1564 |
| 1624 assert(!isMultitest || dartOptions == null); | 1565 assert(!isMultitest || dartOptions == null); |
| 1625 args.add(filePath.toNativePath()); | 1566 args.add(filePath.toNativePath()); |
| 1626 if (dartOptions != null) { | 1567 if (dartOptions != null) { |
| 1627 args.addAll(dartOptions); | 1568 args.addAll(dartOptions); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1726 return readOptionsFromCo19File(filePath); | 1667 return readOptionsFromCo19File(filePath); |
| 1727 } | 1668 } |
| 1728 RegExp testOptionsRegExp = new RegExp(r"// VMOptions=(.*)"); | 1669 RegExp testOptionsRegExp = new RegExp(r"// VMOptions=(.*)"); |
| 1729 RegExp sharedOptionsRegExp = new RegExp(r"// SharedOptions=(.*)"); | 1670 RegExp sharedOptionsRegExp = new RegExp(r"// SharedOptions=(.*)"); |
| 1730 RegExp dartOptionsRegExp = new RegExp(r"// DartOptions=(.*)"); | 1671 RegExp dartOptionsRegExp = new RegExp(r"// DartOptions=(.*)"); |
| 1731 RegExp otherScriptsRegExp = new RegExp(r"// OtherScripts=(.*)"); | 1672 RegExp otherScriptsRegExp = new RegExp(r"// OtherScripts=(.*)"); |
| 1732 RegExp packageRootRegExp = new RegExp(r"// PackageRoot=(.*)"); | 1673 RegExp packageRootRegExp = new RegExp(r"// PackageRoot=(.*)"); |
| 1733 RegExp packagesRegExp = new RegExp(r"// Packages=(.*)"); | 1674 RegExp packagesRegExp = new RegExp(r"// Packages=(.*)"); |
| 1734 RegExp isolateStubsRegExp = new RegExp(r"// IsolateStubs=(.*)"); | 1675 RegExp isolateStubsRegExp = new RegExp(r"// IsolateStubs=(.*)"); |
| 1735 // TODO(gram) Clean these up once the old directives are not supported. | 1676 // TODO(gram) Clean these up once the old directives are not supported. |
| 1736 RegExp domImportRegExp = | 1677 RegExp domImportRegExp = new RegExp( |
| 1737 new RegExp(r"^[#]?import.*dart:(html|web_audio|indexed_db|svg|web_sql)", | 1678 r"^[#]?import.*dart:(html|web_audio|indexed_db|svg|web_sql)", |
| 1738 multiLine: true); | 1679 multiLine: true); |
| 1739 | 1680 |
| 1740 var bytes = new File(filePath.toNativePath()).readAsBytesSync(); | 1681 var bytes = new File(filePath.toNativePath()).readAsBytesSync(); |
| 1741 String contents = decodeUtf8(bytes); | 1682 String contents = decodeUtf8(bytes); |
| 1742 bytes = null; | 1683 bytes = null; |
| 1743 | 1684 |
| 1744 // Find the options in the file. | 1685 // Find the options in the file. |
| 1745 List<List> result = new List<List>(); | 1686 List<List> result = new List<List>(); |
| 1746 List<String> dartOptions; | 1687 List<String> dartOptions; |
| 1747 List<String> sharedOptions; | 1688 List<String> sharedOptions; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1806 | 1747 |
| 1807 bool isMultitest = multiTestRegExp.hasMatch(contents); | 1748 bool isMultitest = multiTestRegExp.hasMatch(contents); |
| 1808 bool isMultiHtmlTest = multiHtmlTestRegExp.hasMatch(contents); | 1749 bool isMultiHtmlTest = multiHtmlTestRegExp.hasMatch(contents); |
| 1809 Match isolateMatch = isolateStubsRegExp.firstMatch(contents); | 1750 Match isolateMatch = isolateStubsRegExp.firstMatch(contents); |
| 1810 String isolateStubs = isolateMatch != null ? isolateMatch[1] : ''; | 1751 String isolateStubs = isolateMatch != null ? isolateMatch[1] : ''; |
| 1811 bool containsDomImport = domImportRegExp.hasMatch(contents); | 1752 bool containsDomImport = domImportRegExp.hasMatch(contents); |
| 1812 | 1753 |
| 1813 List<String> subtestNames = []; | 1754 List<String> subtestNames = []; |
| 1814 Iterator matchesIter = | 1755 Iterator matchesIter = |
| 1815 multiHtmlTestGroupRegExp.allMatches(contents).iterator; | 1756 multiHtmlTestGroupRegExp.allMatches(contents).iterator; |
| 1816 while(matchesIter.moveNext() && isMultiHtmlTest) { | 1757 while (matchesIter.moveNext() && isMultiHtmlTest) { |
| 1817 String fullMatch = matchesIter.current.group(0); | 1758 String fullMatch = matchesIter.current.group(0); |
| 1818 subtestNames.add(fullMatch.substring(fullMatch.indexOf("'") + 1)); | 1759 subtestNames.add(fullMatch.substring(fullMatch.indexOf("'") + 1)); |
| 1819 } | 1760 } |
| 1820 | 1761 |
| 1821 return { "vmOptions": result, | 1762 return { |
| 1822 "sharedOptions": sharedOptions == null ? [] : sharedOptions, | 1763 "vmOptions": result, |
| 1823 "dartOptions": dartOptions, | 1764 "sharedOptions": sharedOptions == null ? [] : sharedOptions, |
| 1824 "packageRoot": packageRoot, | 1765 "dartOptions": dartOptions, |
| 1825 "packages": packages, | 1766 "packageRoot": packageRoot, |
| 1826 "hasCompileError": false, | 1767 "packages": packages, |
| 1827 "hasRuntimeError": false, | 1768 "hasCompileError": false, |
| 1828 "hasStaticWarning" : false, | 1769 "hasRuntimeError": false, |
| 1829 "otherScripts": otherScripts, | 1770 "hasStaticWarning": false, |
| 1830 "isMultitest": isMultitest, | 1771 "otherScripts": otherScripts, |
| 1831 "isMultiHtmlTest": isMultiHtmlTest, | 1772 "isMultitest": isMultitest, |
| 1832 "subtestNames": subtestNames, | 1773 "isMultiHtmlTest": isMultiHtmlTest, |
| 1833 "isolateStubs": isolateStubs, | 1774 "subtestNames": subtestNames, |
| 1834 "containsDomImport": containsDomImport }; | 1775 "isolateStubs": isolateStubs, |
| 1776 "containsDomImport": containsDomImport |
| 1777 }; |
| 1835 } | 1778 } |
| 1836 | 1779 |
| 1837 List<List<String>> getVmOptions(Map optionsFromFile) { | 1780 List<List<String>> getVmOptions(Map optionsFromFile) { |
| 1838 var COMPILERS = const ['none', 'precompiler', 'dart2app']; | 1781 var COMPILERS = const ['none', 'precompiler', 'dart2app']; |
| 1839 var RUNTIMES = const ['none', 'dart_precompiled', 'dart_product', 'vm', | 1782 var RUNTIMES = const [ |
| 1840 'drt', 'dartium', | 1783 'none', |
| 1841 'ContentShellOnAndroid', 'DartiumOnAndroid']; | 1784 'dart_precompiled', |
| 1785 'dart_product', |
| 1786 'vm', |
| 1787 'drt', |
| 1788 'dartium', |
| 1789 'ContentShellOnAndroid', |
| 1790 'DartiumOnAndroid' |
| 1791 ]; |
| 1842 var needsVmOptions = COMPILERS.contains(configuration['compiler']) && | 1792 var needsVmOptions = COMPILERS.contains(configuration['compiler']) && |
| 1843 RUNTIMES.contains(configuration['runtime']); | 1793 RUNTIMES.contains(configuration['runtime']); |
| 1844 if (!needsVmOptions) return [[]]; | 1794 if (!needsVmOptions) return [[]]; |
| 1845 final vmOptions = optionsFromFile['vmOptions']; | 1795 final vmOptions = optionsFromFile['vmOptions']; |
| 1846 return vmOptions; | 1796 return vmOptions; |
| 1847 } | 1797 } |
| 1848 | 1798 |
| 1849 /** | 1799 /** |
| 1850 * Read options from a co19 test file. | 1800 * Read options from a co19 test file. |
| 1851 * | 1801 * |
| 1852 * The reason this is different from [readOptionsFromFile] is that | 1802 * The reason this is different from [readOptionsFromFile] is that |
| 1853 * co19 is developed based on a contract which defines certain test | 1803 * co19 is developed based on a contract which defines certain test |
| 1854 * tags. These tags may appear unused, but should not be removed | 1804 * tags. These tags may appear unused, but should not be removed |
| 1855 * without consulting with the co19 team. | 1805 * without consulting with the co19 team. |
| 1856 * | 1806 * |
| 1857 * Also, [readOptionsFromFile] recognizes a number of additional | 1807 * Also, [readOptionsFromFile] recognizes a number of additional |
| 1858 * tags that are not appropriate for use in general tests of | 1808 * tags that are not appropriate for use in general tests of |
| 1859 * conformance to the Dart language. Any Dart implementation must | 1809 * conformance to the Dart language. Any Dart implementation must |
| 1860 * pass the co19 test suite as is, and not require extra flags, | 1810 * pass the co19 test suite as is, and not require extra flags, |
| 1861 * environment variables, configuration files, etc. | 1811 * environment variables, configuration files, etc. |
| 1862 */ | 1812 */ |
| 1863 Map readOptionsFromCo19File(Path filePath) { | 1813 Map readOptionsFromCo19File(Path filePath) { |
| 1864 String contents = decodeUtf8(new File(filePath.toNativePath()) | 1814 String contents = |
| 1865 .readAsBytesSync()); | 1815 decodeUtf8(new File(filePath.toNativePath()).readAsBytesSync()); |
| 1866 | 1816 |
| 1867 bool hasCompileError = contents.contains("@compile-error"); | 1817 bool hasCompileError = contents.contains("@compile-error"); |
| 1868 bool hasRuntimeError = contents.contains("@runtime-error"); | 1818 bool hasRuntimeError = contents.contains("@runtime-error"); |
| 1869 bool hasStaticWarning = contents.contains("@static-warning"); | 1819 bool hasStaticWarning = contents.contains("@static-warning"); |
| 1870 bool isMultitest = multiTestRegExp.hasMatch(contents); | 1820 bool isMultitest = multiTestRegExp.hasMatch(contents); |
| 1871 | 1821 |
| 1872 return { | 1822 return { |
| 1873 "vmOptions": <List>[[]], | 1823 "vmOptions": <List>[[]], |
| 1874 "sharedOptions": <String>[], | 1824 "sharedOptions": <String>[], |
| 1875 "dartOptions": null, | 1825 "dartOptions": null, |
| 1876 "packageRoot": null, | 1826 "packageRoot": null, |
| 1877 "hasCompileError": hasCompileError, | 1827 "hasCompileError": hasCompileError, |
| 1878 "hasRuntimeError": hasRuntimeError, | 1828 "hasRuntimeError": hasRuntimeError, |
| 1879 "hasStaticWarning" : hasStaticWarning, | 1829 "hasStaticWarning": hasStaticWarning, |
| 1880 "otherScripts": <String>[], | 1830 "otherScripts": <String>[], |
| 1881 "isMultitest": isMultitest, | 1831 "isMultitest": isMultitest, |
| 1882 "isMultiHtmlTest": false, | 1832 "isMultiHtmlTest": false, |
| 1883 "subtestNames": <String>[], | 1833 "subtestNames": <String>[], |
| 1884 "isolateStubs": '', | 1834 "isolateStubs": '', |
| 1885 "containsDomImport": false, | 1835 "containsDomImport": false, |
| 1886 }; | 1836 }; |
| 1887 } | 1837 } |
| 1888 } | 1838 } |
| 1889 | 1839 |
| 1890 | |
| 1891 /// Used for testing packages in on off settings, i.e., we pass in the actual | 1840 /// Used for testing packages in on off settings, i.e., we pass in the actual |
| 1892 /// directory that we want to test. | 1841 /// directory that we want to test. |
| 1893 class PKGTestSuite extends StandardTestSuite { | 1842 class PKGTestSuite extends StandardTestSuite { |
| 1843 PKGTestSuite(Map configuration, Path directoryPath) |
| 1844 : super(configuration, directoryPath.filename, directoryPath, |
| 1845 ["$directoryPath/.status"], |
| 1846 isTestFilePredicate: (f) => f.endsWith('_test.dart'), |
| 1847 recursive: true); |
| 1894 | 1848 |
| 1895 PKGTestSuite(Map configuration, Path directoryPath) | 1849 void enqueueBrowserTest(List<Command> baseCommands, Path packageRoot, |
| 1896 : super(configuration, | 1850 TestInformation info, String testName, expectations) { |
| 1897 directoryPath.filename, | 1851 String runtime = configuration['runtime']; |
| 1898 directoryPath, | 1852 Path filePath = info.filePath; |
| 1899 ["$directoryPath/.status"], | 1853 Path dir = filePath.directoryPath; |
| 1900 isTestFilePredicate: (f) => f.endsWith('_test.dart'), | 1854 String nameNoExt = filePath.filenameWithoutExtension; |
| 1901 recursive: true); | 1855 Path customHtmlPath = dir.append('$nameNoExt.html'); |
| 1856 File customHtml = new File(customHtmlPath.toNativePath()); |
| 1857 if (!customHtml.existsSync()) { |
| 1858 super.enqueueBrowserTest( |
| 1859 baseCommands, packageRoot, info, testName, expectations); |
| 1860 } else { |
| 1861 Path relativeHtml = customHtmlPath.relativeTo(TestUtils.dartDir); |
| 1862 List<Command> commands = []..addAll(baseCommands); |
| 1863 var fullPath = _createUrlPathFromFile(customHtmlPath); |
| 1902 | 1864 |
| 1903 void enqueueBrowserTest(List<Command> baseCommands, | 1865 commands.add(CommandBuilder.instance.getBrowserTestCommand( |
| 1904 Path packageRoot, | 1866 runtime, fullPath, configuration, !isNegative(info))); |
| 1905 TestInformation info, | 1867 String testDisplayName = '$suiteName/$testName'; |
| 1906 String testName, | 1868 enqueueNewTestCase(new BrowserTestCase( |
| 1907 expectations) { | 1869 testDisplayName, |
| 1908 String runtime = configuration['runtime']; | 1870 commands, |
| 1909 Path filePath = info.filePath; | 1871 configuration, |
| 1910 Path dir = filePath.directoryPath; | 1872 expectations, |
| 1911 String nameNoExt = filePath.filenameWithoutExtension; | 1873 info, |
| 1912 Path customHtmlPath = dir.append('$nameNoExt.html'); | 1874 isNegative(info), |
| 1913 File customHtml = new File(customHtmlPath.toNativePath()); | 1875 relativeHtml.toNativePath())); |
| 1914 if (!customHtml.existsSync()) { | |
| 1915 super.enqueueBrowserTest(baseCommands, packageRoot, | |
| 1916 info, testName, expectations); | |
| 1917 } else { | |
| 1918 Path relativeHtml = customHtmlPath.relativeTo(TestUtils.dartDir); | |
| 1919 List<Command> commands = []..addAll(baseCommands); | |
| 1920 var fullPath = _createUrlPathFromFile(customHtmlPath); | |
| 1921 | |
| 1922 commands.add(CommandBuilder.instance.getBrowserTestCommand( | |
| 1923 runtime, fullPath, configuration, !isNegative(info))); | |
| 1924 String testDisplayName = '$suiteName/$testName'; | |
| 1925 enqueueNewTestCase(new BrowserTestCase(testDisplayName, | |
| 1926 commands, | |
| 1927 configuration, | |
| 1928 expectations, | |
| 1929 info, | |
| 1930 isNegative(info), | |
| 1931 relativeHtml.toNativePath())); | |
| 1932 | |
| 1933 } | |
| 1934 } | 1876 } |
| 1877 } |
| 1935 } | 1878 } |
| 1936 | 1879 |
| 1937 | |
| 1938 /// A DartcCompilationTestSuite will run dartc on all of the tests. | 1880 /// A DartcCompilationTestSuite will run dartc on all of the tests. |
| 1939 /// | 1881 /// |
| 1940 /// Usually, the result of a dartc run is determined by the output of | 1882 /// Usually, the result of a dartc run is determined by the output of |
| 1941 /// dartc in connection with annotations in the test file. | 1883 /// dartc in connection with annotations in the test file. |
| 1942 class DartcCompilationTestSuite extends StandardTestSuite { | 1884 class DartcCompilationTestSuite extends StandardTestSuite { |
| 1943 List<String> _testDirs; | 1885 List<String> _testDirs; |
| 1944 | 1886 |
| 1945 DartcCompilationTestSuite(Map configuration, | 1887 DartcCompilationTestSuite( |
| 1946 String suiteName, | 1888 Map configuration, |
| 1947 String directoryPath, | 1889 String suiteName, |
| 1948 List<String> this._testDirs, | 1890 String directoryPath, |
| 1949 List<String> expectations) | 1891 List<String> this._testDirs, |
| 1950 : super(configuration, | 1892 List<String> expectations) |
| 1951 suiteName, | 1893 : super(configuration, suiteName, new Path(directoryPath), expectations); |
| 1952 new Path(directoryPath), | |
| 1953 expectations); | |
| 1954 | 1894 |
| 1955 List<String> additionalOptions(Path filePath) { | 1895 List<String> additionalOptions(Path filePath) { |
| 1956 return ['--fatal-warnings', '--fatal-type-errors']; | 1896 return ['--fatal-warnings', '--fatal-type-errors']; |
| 1957 } | 1897 } |
| 1958 | 1898 |
| 1959 Future enqueueTests() { | 1899 Future enqueueTests() { |
| 1960 var group = new FutureGroup(); | 1900 var group = new FutureGroup(); |
| 1961 | 1901 |
| 1962 for (String testDir in _testDirs) { | 1902 for (String testDir in _testDirs) { |
| 1963 Directory dir = new Directory(suiteDir.append(testDir).toNativePath()); | 1903 Directory dir = new Directory(suiteDir.append(testDir).toNativePath()); |
| 1964 if (dir.existsSync()) { | 1904 if (dir.existsSync()) { |
| 1965 enqueueDirectory(dir, group); | 1905 enqueueDirectory(dir, group); |
| 1966 } | 1906 } |
| 1967 } | 1907 } |
| 1968 | 1908 |
| 1969 return group.future; | 1909 return group.future; |
| 1970 } | 1910 } |
| 1971 } | 1911 } |
| 1972 | 1912 |
| 1973 | |
| 1974 class AnalyzeLibraryTestSuite extends DartcCompilationTestSuite { | 1913 class AnalyzeLibraryTestSuite extends DartcCompilationTestSuite { |
| 1975 AnalyzeLibraryTestSuite(Map configuration) | 1914 AnalyzeLibraryTestSuite(Map configuration) |
| 1976 : super(configuration, | 1915 : super(configuration, 'analyze_library', 'sdk', ['lib'], |
| 1977 'analyze_library', | 1916 ['tests/lib/analyzer/analyze_library.status']); |
| 1978 'sdk', | |
| 1979 ['lib'], | |
| 1980 ['tests/lib/analyzer/analyze_library.status']); | |
| 1981 | 1917 |
| 1982 List<String> additionalOptions(Path filePath, {bool showSdkWarnings}) { | 1918 List<String> additionalOptions(Path filePath, {bool showSdkWarnings}) { |
| 1983 var options = super.additionalOptions(filePath); | 1919 var options = super.additionalOptions(filePath); |
| 1984 // NOTE: This flag has been deprecated. | 1920 // NOTE: This flag has been deprecated. |
| 1985 options.add('--show-sdk-warnings'); | 1921 options.add('--show-sdk-warnings'); |
| 1986 return options; | 1922 return options; |
| 1987 } | 1923 } |
| 1988 | 1924 |
| 1989 bool isTestFile(String filename) { | 1925 bool isTestFile(String filename) { |
| 1990 // NOTE: We exclude tests and patch files for now. | 1926 // NOTE: We exclude tests and patch files for now. |
| 1991 return filename.endsWith(".dart") && | 1927 return filename.endsWith(".dart") && |
| 1992 !filename.endsWith("_test.dart") && | 1928 !filename.endsWith("_test.dart") && |
| 1993 !filename.contains("_internal/js_runtime/lib"); | 1929 !filename.contains("_internal/js_runtime/lib"); |
| 1994 } | 1930 } |
| 1995 | 1931 |
| 1996 bool get listRecursively => true; | 1932 bool get listRecursively => true; |
| 1997 } | 1933 } |
| 1998 | 1934 |
| 1999 | |
| 2000 class PkgBuildTestSuite extends TestSuite { | 1935 class PkgBuildTestSuite extends TestSuite { |
| 2001 final String statusFilePath; | 1936 final String statusFilePath; |
| 2002 | 1937 |
| 2003 PkgBuildTestSuite(Map configuration, String suiteName, this.statusFilePath) | 1938 PkgBuildTestSuite(Map configuration, String suiteName, this.statusFilePath) |
| 2004 : super(configuration, suiteName) { | 1939 : super(configuration, suiteName) { |
| 2005 assert(configuration['use_sdk']);; | 1940 assert(configuration['use_sdk']); |
| 1941 ; |
| 2006 } | 1942 } |
| 2007 | 1943 |
| 2008 void forEachTest(void onTest(TestCase testCase), _, [void onDone()]) { | 1944 void forEachTest(void onTest(TestCase testCase), _, [void onDone()]) { |
| 2009 bool fileExists(Path path) => new File(path.toNativePath()).existsSync(); | 1945 bool fileExists(Path path) => new File(path.toNativePath()).existsSync(); |
| 2010 | 1946 |
| 2011 bool dirExists(Path path) | 1947 bool dirExists(Path path) => |
| 2012 => new Directory(path.toNativePath()).existsSync(); | 1948 new Directory(path.toNativePath()).existsSync(); |
| 2013 | 1949 |
| 2014 enqueueTestCases(Map<String, String> localPackageDirectories, | 1950 enqueueTestCases( |
| 2015 Map<String, String> localSampleDirectories, | 1951 Map<String, String> localPackageDirectories, |
| 2016 TestExpectations testExpectations) { | 1952 Map<String, String> localSampleDirectories, |
| 1953 TestExpectations testExpectations) { |
| 2017 enqueueTestCase(String packageName, String directory) { | 1954 enqueueTestCase(String packageName, String directory) { |
| 2018 var absoluteDirectoryPath = new Path(directory); | 1955 var absoluteDirectoryPath = new Path(directory); |
| 2019 | 1956 |
| 2020 // Early return if this package is not using pub. | 1957 // Early return if this package is not using pub. |
| 2021 if (!fileExists(absoluteDirectoryPath.append('pubspec.yaml'))) { | 1958 if (!fileExists(absoluteDirectoryPath.append('pubspec.yaml'))) { |
| 2022 return; | 1959 return; |
| 2023 } | 1960 } |
| 2024 | 1961 |
| 2025 var directoryPath = | 1962 var directoryPath = absoluteDirectoryPath.relativeTo(TestUtils.dartDir); |
| 2026 absoluteDirectoryPath.relativeTo(TestUtils.dartDir); | |
| 2027 var testName = "$directoryPath"; | 1963 var testName = "$directoryPath"; |
| 2028 var displayName = '$suiteName/$testName'; | 1964 var displayName = '$suiteName/$testName'; |
| 2029 var packageName = directoryPath.filename; | 1965 var packageName = directoryPath.filename; |
| 2030 | 1966 |
| 2031 // Collect necessary paths for pubspec.yaml overrides, pub-cache, ... | 1967 // Collect necessary paths for pubspec.yaml overrides, pub-cache, ... |
| 2032 var checkoutDir = | 1968 var checkoutDir = |
| 2033 createPubPackageBuildsDirectory(absoluteDirectoryPath); | 1969 createPubPackageBuildsDirectory(absoluteDirectoryPath); |
| 2034 var cacheDir = new Path(checkoutDir).append("pub-cache").toNativePath(); | 1970 var cacheDir = new Path(checkoutDir).append("pub-cache").toNativePath(); |
| 2035 var pubspecYamlFile = | 1971 var pubspecYamlFile = |
| 2036 new Path(checkoutDir).append('pubspec.yaml').toNativePath(); | 1972 new Path(checkoutDir).append('pubspec.yaml').toNativePath(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2048 packageDirectories.remove(packageName); | 1984 packageDirectories.remove(packageName); |
| 2049 } | 1985 } |
| 2050 } | 1986 } |
| 2051 var dependencyOverrides = | 1987 var dependencyOverrides = |
| 2052 buildPubspecDependencyOverrides(packageDirectories); | 1988 buildPubspecDependencyOverrides(packageDirectories); |
| 2053 | 1989 |
| 2054 // Build all commands | 1990 // Build all commands |
| 2055 var commands = new List<Command>(); | 1991 var commands = new List<Command>(); |
| 2056 commands.add( | 1992 commands.add( |
| 2057 CommandBuilder.instance.getCopyCommand(directory, checkoutDir)); | 1993 CommandBuilder.instance.getCopyCommand(directory, checkoutDir)); |
| 2058 commands.add(CommandBuilder.instance.getModifyPubspecCommand( | 1994 commands.add(CommandBuilder.instance |
| 2059 pubspecYamlFile, dependencyOverrides)); | 1995 .getModifyPubspecCommand(pubspecYamlFile, dependencyOverrides)); |
| 2060 commands.add(CommandBuilder.instance.getPubCommand( | 1996 commands.add(CommandBuilder.instance |
| 2061 "get", pubPath, checkoutDir, cacheDir)); | 1997 .getPubCommand("get", pubPath, checkoutDir, cacheDir)); |
| 2062 | 1998 |
| 2063 bool containsWebDirectory = dirExists(directoryPath.append('web')); | 1999 bool containsWebDirectory = dirExists(directoryPath.append('web')); |
| 2064 bool containsBuildDartFile = | 2000 bool containsBuildDartFile = |
| 2065 fileExists(directoryPath.append('build.dart')); | 2001 fileExists(directoryPath.append('build.dart')); |
| 2066 if (containsBuildDartFile) { | 2002 if (containsBuildDartFile) { |
| 2067 var dartBinary = new File(dartVmBinaryFileName).absolute.path; | 2003 var dartBinary = new File(dartVmBinaryFileName).absolute.path; |
| 2068 | 2004 |
| 2069 commands.add(CommandBuilder.instance.getProcessCommand( | 2005 commands.add(CommandBuilder.instance.getProcessCommand( |
| 2070 "custom_build", dartBinary, ['build.dart'], | 2006 "custom_build", |
| 2071 {'PUB_CACHE': cacheDir}, checkoutDir)); | 2007 dartBinary, |
| 2008 ['build.dart'], |
| 2009 {'PUB_CACHE': cacheDir}, |
| 2010 checkoutDir)); |
| 2072 | 2011 |
| 2073 // We only try to deploy the application if it's a webapp. | 2012 // We only try to deploy the application if it's a webapp. |
| 2074 if (containsWebDirectory) { | 2013 if (containsWebDirectory) { |
| 2075 commands.add(CommandBuilder.instance.getProcessCommand( | 2014 commands.add(CommandBuilder.instance.getProcessCommand( |
| 2076 "custom_deploy", dartBinary, ['build.dart', '--deploy'], | 2015 "custom_deploy", |
| 2077 {'PUB_CACHE': cacheDir}, checkoutDir)); | 2016 dartBinary, |
| 2017 ['build.dart', '--deploy'], |
| 2018 {'PUB_CACHE': cacheDir}, |
| 2019 checkoutDir)); |
| 2078 } | 2020 } |
| 2079 } else if (containsWebDirectory) { | 2021 } else if (containsWebDirectory) { |
| 2080 commands.add(CommandBuilder.instance.getPubCommand( | 2022 commands.add(CommandBuilder.instance |
| 2081 "build", pubPath, checkoutDir, cacheDir)); | 2023 .getPubCommand("build", pubPath, checkoutDir, cacheDir)); |
| 2082 } | 2024 } |
| 2083 | 2025 |
| 2084 // Enqueue TestCase | 2026 // Enqueue TestCase |
| 2085 var testCase = new TestCase(displayName, | 2027 var testCase = new TestCase(displayName, commands, configuration, |
| 2086 commands, configuration, testExpectations.expectations(testName)); | 2028 testExpectations.expectations(testName)); |
| 2087 enqueueNewTestCase(testCase); | 2029 enqueueNewTestCase(testCase); |
| 2088 } | 2030 } |
| 2089 | 2031 |
| 2090 localPackageDirectories.forEach(enqueueTestCase); | 2032 localPackageDirectories.forEach(enqueueTestCase); |
| 2091 localSampleDirectories.forEach(enqueueTestCase); | 2033 localSampleDirectories.forEach(enqueueTestCase); |
| 2092 | 2034 |
| 2093 doTest = null; | 2035 doTest = null; |
| 2094 // Notify we're done | 2036 // Notify we're done |
| 2095 if (onDone != null) onDone(); | 2037 if (onDone != null) onDone(); |
| 2096 } | 2038 } |
| 2097 | 2039 |
| 2098 doTest = onTest; | 2040 doTest = onTest; |
| 2099 List<String> statusFiles = [ | 2041 List<String> statusFiles = [ |
| 2100 TestUtils.dartDir.join(new Path(statusFilePath)).toNativePath()]; | 2042 TestUtils.dartDir.join(new Path(statusFilePath)).toNativePath() |
| 2043 ]; |
| 2101 ReadTestExpectations(statusFiles, configuration).then((expectations) { | 2044 ReadTestExpectations(statusFiles, configuration).then((expectations) { |
| 2102 Future.wait([discoverPackagesInRepository(), | 2045 Future.wait([ |
| 2103 discoverSamplesInRepository()]).then((List results) { | 2046 discoverPackagesInRepository(), |
| 2047 discoverSamplesInRepository() |
| 2048 ]).then((List results) { |
| 2104 Map packageDirectories = results[0]; | 2049 Map packageDirectories = results[0]; |
| 2105 Map sampleDirectories = results[1]; | 2050 Map sampleDirectories = results[1]; |
| 2106 enqueueTestCases(packageDirectories, sampleDirectories, expectations); | 2051 enqueueTestCases(packageDirectories, sampleDirectories, expectations); |
| 2107 }); | 2052 }); |
| 2108 }); | 2053 }); |
| 2109 } | 2054 } |
| 2110 } | 2055 } |
| 2111 | 2056 |
| 2112 | |
| 2113 class LastModifiedCache { | 2057 class LastModifiedCache { |
| 2114 Map<String, DateTime> _cache = <String, DateTime>{}; | 2058 Map<String, DateTime> _cache = <String, DateTime>{}; |
| 2115 | 2059 |
| 2116 /** | 2060 /** |
| 2117 * Returns the last modified date of the given [uri]. | 2061 * Returns the last modified date of the given [uri]. |
| 2118 * | 2062 * |
| 2119 * The return value will be cached for future queries. If [uri] is a local | 2063 * The return value will be cached for future queries. If [uri] is a local |
| 2120 * file, it's last modified [Date] will be returned. If the file does not | 2064 * file, it's last modified [Date] will be returned. If the file does not |
| 2121 * exist, null will be returned instead. | 2065 * exist, null will be returned instead. |
| 2122 * In case [uri] is not a local file, this method will always return | 2066 * In case [uri] is not a local file, this method will always return |
| 2123 * the current date. | 2067 * the current date. |
| 2124 */ | 2068 */ |
| 2125 DateTime getLastModified(Uri uri) { | 2069 DateTime getLastModified(Uri uri) { |
| 2126 if (uri.scheme == "file") { | 2070 if (uri.scheme == "file") { |
| 2127 if (_cache.containsKey(uri.path)) { | 2071 if (_cache.containsKey(uri.path)) { |
| 2128 return _cache[uri.path]; | 2072 return _cache[uri.path]; |
| 2129 } | 2073 } |
| 2130 var file = new File(new Path(uri.path).toNativePath()); | 2074 var file = new File(new Path(uri.path).toNativePath()); |
| 2131 _cache[uri.path] = file.existsSync() ? file.lastModifiedSync() : null; | 2075 _cache[uri.path] = file.existsSync() ? file.lastModifiedSync() : null; |
| 2132 return _cache[uri.path]; | 2076 return _cache[uri.path]; |
| 2133 } | 2077 } |
| 2134 return new DateTime.now(); | 2078 return new DateTime.now(); |
| 2135 } | 2079 } |
| 2136 } | 2080 } |
| 2137 | 2081 |
| 2138 | |
| 2139 class ExistsCache { | 2082 class ExistsCache { |
| 2140 Map<String, bool> _cache = <String, bool>{}; | 2083 Map<String, bool> _cache = <String, bool>{}; |
| 2141 | 2084 |
| 2142 /** | 2085 /** |
| 2143 * Returns true if the file in [path] exists, false otherwise. | 2086 * Returns true if the file in [path] exists, false otherwise. |
| 2144 * | 2087 * |
| 2145 * The information will be cached. | 2088 * The information will be cached. |
| 2146 */ | 2089 */ |
| 2147 bool doesFileExist(String path) { | 2090 bool doesFileExist(String path) { |
| 2148 if (!_cache.containsKey(path)) { | 2091 if (!_cache.containsKey(path)) { |
| 2149 _cache[path] = new File(path).existsSync(); | 2092 _cache[path] = new File(path).existsSync(); |
| 2150 } | 2093 } |
| 2151 return _cache[path]; | 2094 return _cache[path]; |
| 2152 } | 2095 } |
| 2153 } | 2096 } |
| 2154 | 2097 |
| 2155 | |
| 2156 class TestUtils { | 2098 class TestUtils { |
| 2157 /** | 2099 /** |
| 2158 * Any script using TestUtils must set dartDirUri to a file:// URI | 2100 * Any script using TestUtils must set dartDirUri to a file:// URI |
| 2159 * pointing to the root of the Dart checkout. | 2101 * pointing to the root of the Dart checkout. |
| 2160 */ | 2102 */ |
| 2161 static setDartDirUri(uri) { | 2103 static setDartDirUri(uri) { |
| 2162 dartDirUri = uri; | 2104 dartDirUri = uri; |
| 2163 dartDir = new Path(uri.toFilePath()); | 2105 dartDir = new Path(uri.toFilePath()); |
| 2164 } | 2106 } |
| 2107 |
| 2165 static Random rand = new Random.secure(); | 2108 static Random rand = new Random.secure(); |
| 2166 static Uri dartDirUri; | 2109 static Uri dartDirUri; |
| 2167 static Path dartDir; | 2110 static Path dartDir; |
| 2168 static LastModifiedCache lastModifiedCache = new LastModifiedCache(); | 2111 static LastModifiedCache lastModifiedCache = new LastModifiedCache(); |
| 2169 static ExistsCache existsCache = new ExistsCache(); | 2112 static ExistsCache existsCache = new ExistsCache(); |
| 2170 static Path currentWorkingDirectory = | 2113 static Path currentWorkingDirectory = new Path(Directory.current.path); |
| 2171 new Path(Directory.current.path); | |
| 2172 | 2114 |
| 2173 /** | 2115 /** |
| 2174 * Generates a random number. | 2116 * Generates a random number. |
| 2175 */ | 2117 */ |
| 2176 static int getRandomNumber() { | 2118 static int getRandomNumber() { |
| 2177 return rand.nextInt(0xffffffff); | 2119 return rand.nextInt(0xffffffff); |
| 2178 } | 2120 } |
| 2179 | 2121 |
| 2180 /** | 2122 /** |
| 2181 * Creates a directory using a [relativePath] to an existing | 2123 * Creates a directory using a [relativePath] to an existing |
| (...skipping 21 matching lines...) Expand all Loading... |
| 2203 assert(dir.existsSync()); | 2145 assert(dir.existsSync()); |
| 2204 } | 2146 } |
| 2205 return dir; | 2147 return dir; |
| 2206 } | 2148 } |
| 2207 | 2149 |
| 2208 /** | 2150 /** |
| 2209 * Copy a [source] file to a new place. | 2151 * Copy a [source] file to a new place. |
| 2210 * Assumes that the directory for [dest] already exists. | 2152 * Assumes that the directory for [dest] already exists. |
| 2211 */ | 2153 */ |
| 2212 static Future copyFile(Path source, Path dest) { | 2154 static Future copyFile(Path source, Path dest) { |
| 2213 return new File(source.toNativePath()).openRead() | 2155 return new File(source.toNativePath()) |
| 2156 .openRead() |
| 2214 .pipe(new File(dest.toNativePath()).openWrite()); | 2157 .pipe(new File(dest.toNativePath()).openWrite()); |
| 2215 } | 2158 } |
| 2216 | 2159 |
| 2217 static Future copyDirectory(String source, String dest) { | 2160 static Future copyDirectory(String source, String dest) { |
| 2218 source = new Path(source).toNativePath(); | 2161 source = new Path(source).toNativePath(); |
| 2219 dest = new Path(dest).toNativePath(); | 2162 dest = new Path(dest).toNativePath(); |
| 2220 | 2163 |
| 2221 var executable = 'cp'; | 2164 var executable = 'cp'; |
| 2222 var args = ['-Rp', source, dest]; | 2165 var args = ['-Rp', source, dest]; |
| 2223 if (Platform.operatingSystem == 'windows') { | 2166 if (Platform.operatingSystem == 'windows') { |
| 2224 executable = 'xcopy'; | 2167 executable = 'xcopy'; |
| 2225 args = [source, dest, '/e', '/i']; | 2168 args = [source, dest, '/e', '/i']; |
| 2226 } | 2169 } |
| 2227 return Process.run(executable, args).then((ProcessResult result) { | 2170 return Process.run(executable, args).then((ProcessResult result) { |
| 2228 if (result.exitCode != 0) { | 2171 if (result.exitCode != 0) { |
| 2229 throw new Exception("Failed to execute '$executable " | 2172 throw new Exception("Failed to execute '$executable " |
| 2230 "${args.join(' ')}'."); | 2173 "${args.join(' ')}'."); |
| 2231 } | 2174 } |
| 2232 }); | 2175 }); |
| 2233 } | 2176 } |
| 2234 | 2177 |
| 2235 static Future deleteDirectory(String path) { | 2178 static Future deleteDirectory(String path) { |
| 2236 // We are seeing issues with long path names on windows when | 2179 // We are seeing issues with long path names on windows when |
| 2237 // deleting them. Use the system tools to delete our long paths. | 2180 // deleting them. Use the system tools to delete our long paths. |
| 2238 // See issue 16264. | 2181 // See issue 16264. |
| 2239 if (Platform.operatingSystem == 'windows') { | 2182 if (Platform.operatingSystem == 'windows') { |
| 2240 var native_path = new Path(path).toNativePath(); | 2183 var native_path = new Path(path).toNativePath(); |
| 2241 // Running this in a shell sucks, but rmdir is not part of the standard | 2184 // Running this in a shell sucks, but rmdir is not part of the standard |
| 2242 // path. | 2185 // path. |
| 2243 return Process.run('rmdir', ['/s', '/q', native_path], runInShell: true) | 2186 return Process |
| 2244 .then((ProcessResult result) { | 2187 .run('rmdir', ['/s', '/q', native_path], runInShell: true) |
| 2245 if (result.exitCode != 0) { | 2188 .then((ProcessResult result) { |
| 2246 throw new Exception('Can\'t delete path $native_path. ' | 2189 if (result.exitCode != 0) { |
| 2247 'This path might be too long'); | 2190 throw new Exception('Can\'t delete path $native_path. ' |
| 2248 } | 2191 'This path might be too long'); |
| 2249 }); | 2192 } |
| 2193 }); |
| 2250 } else { | 2194 } else { |
| 2251 var dir = new Directory(path); | 2195 var dir = new Directory(path); |
| 2252 return dir.delete(recursive: true); | 2196 return dir.delete(recursive: true); |
| 2253 } | 2197 } |
| 2254 } | 2198 } |
| 2255 | 2199 |
| 2256 static deleteTempSnapshotDirectory(Map configuration) { | 2200 static deleteTempSnapshotDirectory(Map configuration) { |
| 2257 if (configuration['compiler'] == 'dart2app') { | 2201 if (configuration['compiler'] == 'dart2app') { |
| 2258 var checked = configuration['checked'] ? '-checked' : ''; | 2202 var checked = configuration['checked'] ? '-checked' : ''; |
| 2259 var minified = configuration['minified'] ? '-minified' : ''; | 2203 var minified = configuration['minified'] ? '-minified' : ''; |
| 2260 var csp = configuration['csp'] ? '-csp' : ''; | 2204 var csp = configuration['csp'] ? '-csp' : ''; |
| 2261 var sdk = configuration['use_sdk'] ? '-sdk' : ''; | 2205 var sdk = configuration['use_sdk'] ? '-sdk' : ''; |
| 2262 var packages = configuration['use_public_packages'] | 2206 var packages = |
| 2263 ? '-public_packages' : ''; | 2207 configuration['use_public_packages'] ? '-public_packages' : ''; |
| 2264 var dirName = "${configuration['compiler']}" | 2208 var dirName = "${configuration['compiler']}" |
| 2265 "$checked$minified$csp$packages$sdk"; | 2209 "$checked$minified$csp$packages$sdk"; |
| 2266 String generatedPath = "${TestUtils.buildDir(configuration)}" | 2210 String generatedPath = "${TestUtils.buildDir(configuration)}" |
| 2267 "/generated_compilations/$dirName"; | 2211 "/generated_compilations/$dirName"; |
| 2268 TestUtils.deleteDirectory(generatedPath); | 2212 TestUtils.deleteDirectory(generatedPath); |
| 2269 } | 2213 } |
| 2270 } | 2214 } |
| 2271 | 2215 |
| 2272 static Path debugLogfile() { | 2216 static Path debugLogfile() { |
| 2273 return new Path(".debug.log"); | 2217 return new Path(".debug.log"); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2321 args = ['--generate-code-with-compile-time-errors', '--test-mode']; | 2265 args = ['--generate-code-with-compile-time-errors', '--test-mode']; |
| 2322 if (configuration["checked"]) { | 2266 if (configuration["checked"]) { |
| 2323 args.add('--enable-checked-mode'); | 2267 args.add('--enable-checked-mode'); |
| 2324 } | 2268 } |
| 2325 // args.add("--verbose"); | 2269 // args.add("--verbose"); |
| 2326 if (!isBrowserRuntime(configuration['runtime'])) { | 2270 if (!isBrowserRuntime(configuration['runtime'])) { |
| 2327 args.add("--allow-mock-compilation"); | 2271 args.add("--allow-mock-compilation"); |
| 2328 args.add("--categories=all"); | 2272 args.add("--categories=all"); |
| 2329 } | 2273 } |
| 2330 } | 2274 } |
| 2331 if ((compiler == "dart2js") && | 2275 if ((compiler == "dart2js") && configuration["minified"]) { |
| 2332 configuration["minified"]) { | |
| 2333 args.add("--minify"); | 2276 args.add("--minify"); |
| 2334 } | 2277 } |
| 2335 if (compiler == "dart2js" && configuration["csp"]) { | 2278 if (compiler == "dart2js" && configuration["csp"]) { |
| 2336 args.add("--csp"); | 2279 args.add("--csp"); |
| 2337 } | 2280 } |
| 2338 if (compiler == "dart2js" && configuration["cps_ir"]) { | 2281 if (compiler == "dart2js" && configuration["cps_ir"]) { |
| 2339 args.add("--use-cps-ir"); | 2282 args.add("--use-cps-ir"); |
| 2340 } | 2283 } |
| 2341 if (compiler == "dart2analyzer") { | 2284 if (compiler == "dart2analyzer") { |
| 2342 args.add("--show-package-warnings"); | 2285 args.add("--show-package-warnings"); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2408 throw 'Unrecognized mode configuration: ${configuration['mode']}'; | 2351 throw 'Unrecognized mode configuration: ${configuration['mode']}'; |
| 2409 } | 2352 } |
| 2410 var arch = configuration['arch'].toUpperCase(); | 2353 var arch = configuration['arch'].toUpperCase(); |
| 2411 var normal = '$mode$arch'; | 2354 var normal = '$mode$arch'; |
| 2412 var cross = '${mode}X$arch'; | 2355 var cross = '${mode}X$arch'; |
| 2413 var outDir = outputDir(configuration); | 2356 var outDir = outputDir(configuration); |
| 2414 var normalDir = new Directory(new Path('$outDir$normal').toNativePath()); | 2357 var normalDir = new Directory(new Path('$outDir$normal').toNativePath()); |
| 2415 var crossDir = new Directory(new Path('$outDir$cross').toNativePath()); | 2358 var crossDir = new Directory(new Path('$outDir$cross').toNativePath()); |
| 2416 if (normalDir.existsSync() && crossDir.existsSync()) { | 2359 if (normalDir.existsSync() && crossDir.existsSync()) { |
| 2417 throw "You can't have both $normalDir and $crossDir, we don't know which" | 2360 throw "You can't have both $normalDir and $crossDir, we don't know which" |
| 2418 " binary to use"; | 2361 " binary to use"; |
| 2419 } | 2362 } |
| 2420 if (crossDir.existsSync()) { | 2363 if (crossDir.existsSync()) { |
| 2421 return cross; | 2364 return cross; |
| 2422 } | 2365 } |
| 2423 return normal; | 2366 return normal; |
| 2424 } | 2367 } |
| 2425 | 2368 |
| 2426 /** | 2369 /** |
| 2427 * Gets extra options under [key] passed to the testing script. | 2370 * Gets extra options under [key] passed to the testing script. |
| 2428 */ | 2371 */ |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2461 "tests_co19_src_LayoutTests_fast_canvas_webgl": "co19_canvas_webgl", | 2404 "tests_co19_src_LayoutTests_fast_canvas_webgl": "co19_canvas_webgl", |
| 2462 "tests_co19_src_LibTest_core_AbstractClassInstantiationError_" | 2405 "tests_co19_src_LibTest_core_AbstractClassInstantiationError_" |
| 2463 "AbstractClassInstantiationError_": "co19_abstract_class_", | 2406 "AbstractClassInstantiationError_": "co19_abstract_class_", |
| 2464 "tests_co19_src_LibTest_core_IntegerDivisionByZeroException_" | 2407 "tests_co19_src_LibTest_core_IntegerDivisionByZeroException_" |
| 2465 "IntegerDivisionByZeroException_": "co19_division_by_zero", | 2408 "IntegerDivisionByZeroException_": "co19_division_by_zero", |
| 2466 "tests_co19_src_WebPlatformTest_html_dom_documents_dom-tree-accessors_": | 2409 "tests_co19_src_WebPlatformTest_html_dom_documents_dom-tree-accessors_": |
| 2467 "co19_dom_accessors_", | 2410 "co19_dom_accessors_", |
| 2468 "tests_co19_src_WebPlatformTest_html_semantics_embedded-content_" | 2411 "tests_co19_src_WebPlatformTest_html_semantics_embedded-content_" |
| 2469 "media-elements_": "co19_media_elements", | 2412 "media-elements_": "co19_media_elements", |
| 2470 "tests_co19_src_WebPlatformTest_html_semantics_": "co19_semantics_", | 2413 "tests_co19_src_WebPlatformTest_html_semantics_": "co19_semantics_", |
| 2471 | |
| 2472 "tests_co19_src_WebPlatformTest_html-templates_additions-to-" | 2414 "tests_co19_src_WebPlatformTest_html-templates_additions-to-" |
| 2473 "the-steps-to-clone-a-node_": "co19_htmltemplates_clone_", | 2415 "the-steps-to-clone-a-node_": "co19_htmltemplates_clone_", |
| 2474 "tests_co19_src_WebPlatformTest_html-templates_definitions_" | 2416 "tests_co19_src_WebPlatformTest_html-templates_definitions_" |
| 2475 "template-contents-owner": "co19_htmltemplates_contents", | 2417 "template-contents-owner": "co19_htmltemplates_contents", |
| 2476 "tests_co19_src_WebPlatformTest_html-templates_parsing-html-" | 2418 "tests_co19_src_WebPlatformTest_html-templates_parsing-html-" |
| 2477 "templates_additions-to-": "co19_htmltemplates_add_", | 2419 "templates_additions-to-": "co19_htmltemplates_add_", |
| 2478 "tests_co19_src_WebPlatformTest_html-templates_parsing-html-" | 2420 "tests_co19_src_WebPlatformTest_html-templates_parsing-html-" |
| 2479 "templates_appending-to-a-template_": "co19_htmltemplates_append_", | 2421 "templates_appending-to-a-template_": "co19_htmltemplates_append_", |
| 2480 "tests_co19_src_WebPlatformTest_html-templates_parsing-html-" | 2422 "tests_co19_src_WebPlatformTest_html-templates_parsing-html-" |
| 2481 "templates_clearing-the-stack-back-to-a-given-context_": | 2423 "templates_clearing-the-stack-back-to-a-given-context_": |
| 2482 "co19_htmltemplates_clearstack_", | 2424 "co19_htmltemplates_clearstack_", |
| 2483 "tests_co19_src_WebPlatformTest_html-templates_parsing-html-" | 2425 "tests_co19_src_WebPlatformTest_html-templates_parsing-html-" |
| 2484 "templates_creating-an-element-for-the-token_": | 2426 "templates_creating-an-element-for-the-token_": |
| 2485 "co19_htmltemplates_create_", | 2427 "co19_htmltemplates_create_", |
| 2486 "tests_co19_src_WebPlatformTest_html-templates_template-element" | 2428 "tests_co19_src_WebPlatformTest_html-templates_template-element" |
| 2487 "_template-": "co19_htmltemplates_element-", | 2429 "_template-": "co19_htmltemplates_element-", |
| 2488 "tests_co19_src_WebPlatformTest_html-templates_": "co19_htmltemplate_", | 2430 "tests_co19_src_WebPlatformTest_html-templates_": "co19_htmltemplate_", |
| 2489 | |
| 2490 "tests_co19_src_WebPlatformTest_shadow-dom_shadow-trees_": | 2431 "tests_co19_src_WebPlatformTest_shadow-dom_shadow-trees_": |
| 2491 "co19_shadow-trees_", | 2432 "co19_shadow-trees_", |
| 2492 "tests_co19_src_WebPlatformTest_shadow-dom_elements-and-dom-objects_": | 2433 "tests_co19_src_WebPlatformTest_shadow-dom_elements-and-dom-objects_": |
| 2493 "co19_shadowdom_", | 2434 "co19_shadowdom_", |
| 2494 "tests_co19_src_WebPlatformTest_shadow-dom_html-elements-in-" | 2435 "tests_co19_src_WebPlatformTest_shadow-dom_html-elements-in-" |
| 2495 "shadow-trees_": "co19_shadow_html_", | 2436 "shadow-trees_": "co19_shadow_html_", |
| 2496 "tests_co19_src_WebPlatformTest_html_webappapis_system-state-and-" | 2437 "tests_co19_src_WebPlatformTest_html_webappapis_system-state-and-" |
| 2497 "capabilities_the-navigator-object": "co19_webappapis_navigator_", | 2438 "capabilities_the-navigator-object": "co19_webappapis_navigator_", |
| 2498 "tests_co19_src_WebPlatformTest_DOMEvents_approved_": "co19_dom_approved_" | 2439 "tests_co19_src_WebPlatformTest_DOMEvents_approved_": "co19_dom_approved_" |
| 2499 }; | 2440 }; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2511 for (var key in PATH_REPLACEMENTS.keys) { | 2452 for (var key in PATH_REPLACEMENTS.keys) { |
| 2512 if (path.startsWith(key)) { | 2453 if (path.startsWith(key)) { |
| 2513 path = path.replaceFirst(key, PATH_REPLACEMENTS[key]); | 2454 path = path.replaceFirst(key, PATH_REPLACEMENTS[key]); |
| 2514 break; | 2455 break; |
| 2515 } | 2456 } |
| 2516 } | 2457 } |
| 2517 } | 2458 } |
| 2518 return path; | 2459 return path; |
| 2519 } | 2460 } |
| 2520 } | 2461 } |
| OLD | NEW |