| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Classes and methods for enumerating and preparing tests. | 6 * Classes and methods for enumerating and preparing tests. |
| 7 * | 7 * |
| 8 * This library includes: | 8 * This library includes: |
| 9 * | 9 * |
| 10 * - Creating tests by listing all the Dart files in certain directories, | 10 * - Creating tests by listing all the Dart files in certain directories, |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 // - update SummaryReport | 253 // - update SummaryReport |
| 254 // - handle SKIP/SKIP_BY_DESIGN markers | 254 // - handle SKIP/SKIP_BY_DESIGN markers |
| 255 // - test if the selector matches | 255 // - test if the selector matches |
| 256 // and will enqueue the test (if necessary). | 256 // and will enqueue the test (if necessary). |
| 257 void enqueueNewTestCase(TestCase testCase) { | 257 void enqueueNewTestCase(TestCase testCase) { |
| 258 var expectations = testCase.expectedOutcomes; | 258 var expectations = testCase.expectedOutcomes; |
| 259 | 259 |
| 260 // Handle sharding based on the original test path (i.e. all multitests | 260 // Handle sharding based on the original test path (i.e. all multitests |
| 261 // of a given original test belong to the same shard) | 261 // of a given original test belong to the same shard) |
| 262 int shards = configuration['shards']; | 262 int shards = configuration['shards']; |
| 263 if (shards > 1) { | 263 if (shards > 1 && testCase.hash % shards != configuration['shard'] - 1) { |
| 264 int shard = configuration['shard']; | 264 return; |
| 265 var testPath = | |
| 266 testCase.info.originTestPath.relativeTo(TestUtils.dartDir); | |
| 267 if ("$testPath".hashCode % shards != shard - 1) { | |
| 268 return; | |
| 269 } | |
| 270 } | 265 } |
| 271 // Test if the selector includes this test. | 266 // Test if the selector includes this test. |
| 272 RegExp pattern = configuration['selectors'][suiteName]; | 267 RegExp pattern = configuration['selectors'][suiteName]; |
| 273 if (!pattern.hasMatch(testCase.displayName)) { | 268 if (!pattern.hasMatch(testCase.displayName)) { |
| 274 return; | 269 return; |
| 275 } | 270 } |
| 276 | 271 |
| 277 // Update Summary report | 272 // Update Summary report |
| 278 if (configuration['report']) { | 273 if (configuration['report']) { |
| 279 SummaryReport.add(expectations); | 274 SummaryReport.add(expectations); |
| 280 if (testCase.info != null && | 275 if (testCase.expectCompileError && |
| 281 testCase.expectCompileError && | |
| 282 TestUtils.isBrowserRuntime(configuration['runtime']) && | 276 TestUtils.isBrowserRuntime(configuration['runtime']) && |
| 283 new CompilerConfiguration(configuration).hasCompiler) { | 277 new CompilerConfiguration(configuration).hasCompiler) { |
| 284 SummaryReport.addCompileErrorSkipTest(); | 278 SummaryReport.addCompileErrorSkipTest(); |
| 285 return; | 279 return; |
| 286 } | 280 } |
| 287 } | 281 } |
| 288 | 282 |
| 289 // Handle skipped tests | 283 // Handle skipped tests |
| 290 if (expectations.contains(Expectation.SKIP) || | 284 if (expectations.contains(Expectation.SKIP) || |
| 291 expectations.contains(Expectation.SKIP_BY_DESIGN)) { | 285 expectations.contains(Expectation.SKIP_BY_DESIGN)) { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 * The tests are compiled into a monolithic executable by the build step. | 490 * The tests are compiled into a monolithic executable by the build step. |
| 497 * The executable lists its tests when run with the --list command line flag. | 491 * The executable lists its tests when run with the --list command line flag. |
| 498 * Individual tests are run by specifying them on the command line. | 492 * Individual tests are run by specifying them on the command line. |
| 499 */ | 493 */ |
| 500 class CCTestSuite extends TestSuite { | 494 class CCTestSuite extends TestSuite { |
| 501 final String testPrefix; | 495 final String testPrefix; |
| 502 String targetRunnerPath; | 496 String targetRunnerPath; |
| 503 String hostRunnerPath; | 497 String hostRunnerPath; |
| 504 final String dartDir; | 498 final String dartDir; |
| 505 List<String> statusFilePaths; | 499 List<String> statusFilePaths; |
| 506 VoidFunction doDone; | |
| 507 | 500 |
| 508 CCTestSuite(Map configuration, | 501 CCTestSuite(Map configuration, |
| 509 String suiteName, | 502 String suiteName, |
| 510 String runnerName, | 503 String runnerName, |
| 511 this.statusFilePaths, | 504 this.statusFilePaths, |
| 512 {this.testPrefix: ''}) | 505 {this.testPrefix: ''}) |
| 513 : super(configuration, suiteName), | 506 : super(configuration, suiteName), |
| 514 dartDir = TestUtils.dartDir.toNativePath() { | 507 dartDir = TestUtils.dartDir.toNativePath() { |
| 515 // For running the tests we use the given '$runnerName' binary | 508 // For running the tests we use the given '$runnerName' binary |
| 516 targetRunnerPath = '$buildDir/$runnerName'; | 509 targetRunnerPath = '$buildDir/$runnerName'; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 538 args.add(testName); | 531 args.add(testName); |
| 539 | 532 |
| 540 var command = CommandBuilder.instance.getProcessCommand( | 533 var command = CommandBuilder.instance.getProcessCommand( |
| 541 'run_vm_unittest', targetRunnerPath, args, environmentOverrides); | 534 'run_vm_unittest', targetRunnerPath, args, environmentOverrides); |
| 542 enqueueNewTestCase( | 535 enqueueNewTestCase( |
| 543 new TestCase(constructedName, [command], configuration, expectations)); | 536 new TestCase(constructedName, [command], configuration, expectations)); |
| 544 } | 537 } |
| 545 | 538 |
| 546 void forEachTest(Function onTest, Map testCache, [VoidFunction onDone]) { | 539 void forEachTest(Function onTest, Map testCache, [VoidFunction onDone]) { |
| 547 doTest = onTest; | 540 doTest = onTest; |
| 548 doDone = onDone; | |
| 549 | |
| 550 var statusFiles = | 541 var statusFiles = |
| 551 statusFilePaths.map((statusFile) => "$dartDir/$statusFile").toList(); | 542 statusFilePaths.map((statusFile) => "$dartDir/$statusFile").toList(); |
| 552 | 543 |
| 553 ReadTestExpectations(statusFiles, configuration) | 544 ReadTestExpectations(statusFiles, configuration) |
| 554 .then((TestExpectations expectations) { | 545 .then((TestExpectations expectations) { |
| 555 ccTestLister(hostRunnerPath).then((Iterable<String> names) { | 546 ccTestLister(hostRunnerPath).then((Iterable<String> names) { |
| 556 names.forEach((testName) => testNameHandler(expectations, testName)); | 547 names.forEach((testName) => testNameHandler(expectations, testName)); |
| 557 onDone(); | 548 doTest = null; |
| 549 if (onDone != null) onDone(); |
| 558 }).catchError((error) { | 550 }).catchError((error) { |
| 559 print("Fatal error occured: $error"); | 551 print("Fatal error occured: $error"); |
| 560 exit(1); | 552 exit(1); |
| 561 }); | 553 }); |
| 562 }); | 554 }); |
| 563 } | 555 } |
| 564 } | 556 } |
| 565 | 557 |
| 566 | 558 |
| 567 class TestInformation { | 559 class TestInformation { |
| (...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1803 | 1795 |
| 1804 // Enqueue TestCase | 1796 // Enqueue TestCase |
| 1805 var testCase = new TestCase(displayName, | 1797 var testCase = new TestCase(displayName, |
| 1806 commands, configuration, testExpectations.expectations(testName)); | 1798 commands, configuration, testExpectations.expectations(testName)); |
| 1807 enqueueNewTestCase(testCase); | 1799 enqueueNewTestCase(testCase); |
| 1808 } | 1800 } |
| 1809 | 1801 |
| 1810 localPackageDirectories.forEach(enqueueTestCase); | 1802 localPackageDirectories.forEach(enqueueTestCase); |
| 1811 localSampleDirectories.forEach(enqueueTestCase); | 1803 localSampleDirectories.forEach(enqueueTestCase); |
| 1812 | 1804 |
| 1805 doTest = null; |
| 1813 // Notify we're done | 1806 // Notify we're done |
| 1814 if (onDone != null) onDone(); | 1807 if (onDone != null) onDone(); |
| 1815 } | 1808 } |
| 1816 | 1809 |
| 1817 doTest = onTest; | 1810 doTest = onTest; |
| 1818 Map<String, String> _localPackageDirectories; | 1811 Map<String, String> _localPackageDirectories; |
| 1819 Map<String, String> _localSampleDirectories; | 1812 Map<String, String> _localSampleDirectories; |
| 1820 List<String> statusFiles = [ | 1813 List<String> statusFiles = [ |
| 1821 TestUtils.dartDir.join(new Path(statusFilePath)).toNativePath()]; | 1814 TestUtils.dartDir.join(new Path(statusFilePath)).toNativePath()]; |
| 1822 ReadTestExpectations(statusFiles, configuration).then((expectations) { | 1815 ReadTestExpectations(statusFiles, configuration).then((expectations) { |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2216 * $pass tests are expected to pass | 2209 * $pass tests are expected to pass |
| 2217 * $failOk tests are expected to fail that we won't fix | 2210 * $failOk tests are expected to fail that we won't fix |
| 2218 * $fail tests are expected to fail that we should fix | 2211 * $fail tests are expected to fail that we should fix |
| 2219 * $crash tests are expected to crash that we should fix | 2212 * $crash tests are expected to crash that we should fix |
| 2220 * $timeout tests are allowed to timeout | 2213 * $timeout tests are allowed to timeout |
| 2221 * $compileErrorSkip tests are skipped on browsers due to compile-time error | 2214 * $compileErrorSkip tests are skipped on browsers due to compile-time error |
| 2222 """; | 2215 """; |
| 2223 print(report); | 2216 print(report); |
| 2224 } | 2217 } |
| 2225 } | 2218 } |
| OLD | NEW |