| 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 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 globalTemporaryDirectory = globalTempDir; | 238 globalTemporaryDirectory = globalTempDir; |
| 239 | 239 |
| 240 var filesRead = 0; | 240 var filesRead = 0; |
| 241 void statusFileRead() { | 241 void statusFileRead() { |
| 242 filesRead++; | 242 filesRead++; |
| 243 if (filesRead == statusFilePaths.length) { | 243 if (filesRead == statusFilePaths.length) { |
| 244 // Checked if we have already found and generated the tests for | 244 // Checked if we have already found and generated the tests for |
| 245 // this suite. | 245 // this suite. |
| 246 if (!testCache.containsKey(suiteName)) { | 246 if (!testCache.containsKey(suiteName)) { |
| 247 cachedTests = testCache[suiteName] = []; | 247 cachedTests = testCache[suiteName] = []; |
| 248 if (configuration['shards'] > 1) { |
| 249 // If we are sharding tests, we do not enqueue them as they are |
| 250 // found in the directory listing. We add all the tests to the |
| 251 // testCache, then delete all but this shard's tests from the |
| 252 // cache. The doDone function then enqueues the tests from the |
| 253 // cache, and other configurations also use the shard from the |
| 254 // cache. |
| 255 Function oldDone = doDone; |
| 256 doDone = () { |
| 257 testCache[suiteName] = shardTests(); |
| 258 for (var info in testCache[suiteName]) { |
| 259 enqueueTestCaseFromTestInformation(info); |
| 260 } |
| 261 oldDone(); |
| 262 }; |
| 263 } |
| 248 processDirectory(); | 264 processDirectory(); |
| 249 } else { | 265 } else { |
| 250 // We rely on enqueueing completing asynchronously so use a | 266 // We rely on enqueueing completing asynchronously so use a |
| 251 // timer to make it so. | 267 // timer to make it so. |
| 252 void enqueueCachedTests(Timer ignore) { | 268 void enqueueCachedTests(Timer ignore) { |
| 253 for (var info in testCache[suiteName]) { | 269 for (var info in testCache[suiteName]) { |
| 254 enqueueTestCaseFromTestInformation(info); | 270 enqueueTestCaseFromTestInformation(info); |
| 255 } | 271 } |
| 256 doDone(); | 272 doDone(); |
| 257 } | 273 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 Set<String> multitestOutcome = null]) { | 398 Set<String> multitestOutcome = null]) { |
| 383 // Cache the test information for each test case. | 399 // Cache the test information for each test case. |
| 384 var info = new TestInformation(filename, | 400 var info = new TestInformation(filename, |
| 385 optionsFromFile, | 401 optionsFromFile, |
| 386 isNegative, | 402 isNegative, |
| 387 isNegativeIfChecked, | 403 isNegativeIfChecked, |
| 388 hasFatalTypeErrors, | 404 hasFatalTypeErrors, |
| 389 hasRuntimeErrors, | 405 hasRuntimeErrors, |
| 390 multitestOutcome); | 406 multitestOutcome); |
| 391 cachedTests.add(info); | 407 cachedTests.add(info); |
| 392 enqueueTestCaseFromTestInformation(info); | 408 if (configuration['shards'] == 1) { |
| 409 // If we are not sharding, we queue the tests as we find them. |
| 410 enqueueTestCaseFromTestInformation(info); |
| 411 } |
| 393 }; | 412 }; |
| 394 } | 413 } |
| 395 | 414 |
| 396 void processFile(String filename) { | 415 void processFile(String filename) { |
| 397 if (!isTestFile(filename)) return; | 416 if (!isTestFile(filename)) return; |
| 398 | 417 |
| 399 // Only run the tests that match the pattern. | 418 // Only run the tests that match the pattern. |
| 400 RegExp pattern = configuration['selectors'][suiteName]; | 419 RegExp pattern = configuration['selectors'][suiteName]; |
| 401 if (!pattern.hasMatch(filename)) return; | 420 if (!pattern.hasMatch(filename)) return; |
| 402 if (filename.endsWith('test_config.dart')) return; | 421 if (filename.endsWith('test_config.dart')) return; |
| (...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 865 "otherScripts": otherScripts, | 884 "otherScripts": otherScripts, |
| 866 "isMultitest": isMultitest, | 885 "isMultitest": isMultitest, |
| 867 "containsLeadingHash": containsLeadingHash, | 886 "containsLeadingHash": containsLeadingHash, |
| 868 "isolateStubs": isolateStubs, | 887 "isolateStubs": isolateStubs, |
| 869 "containsDomImport": containsDomImport, | 888 "containsDomImport": containsDomImport, |
| 870 "isLibraryDefinition": isLibraryDefinition, | 889 "isLibraryDefinition": isLibraryDefinition, |
| 871 "containsSourceOrImport": containsSourceOrImport, | 890 "containsSourceOrImport": containsSourceOrImport, |
| 872 "numStaticTypeAnnotations": numStaticTypeAnnotations, | 891 "numStaticTypeAnnotations": numStaticTypeAnnotations, |
| 873 "numCompileTimeAnnotations": numCompileTimeAnnotations}; | 892 "numCompileTimeAnnotations": numCompileTimeAnnotations}; |
| 874 } | 893 } |
| 894 |
| 895 /** |
| 896 * shardTests takes the list of tests, stored as the List<TestInformation> |
| 897 * cachedTests, and selects only the tests belonging to this shard. |
| 898 * The tests are sorted by filename, and if there are n shards and we are |
| 899 * shard number i, only the tests at indices equal to i-1 modulo n are kept. |
| 900 */ |
| 901 List<TestInformation> shardTests() { |
| 902 cachedTests.sort((TestInformation a, TestInformation b) => a.filename.compar
eTo(b.filename)); |
| 903 int n = configuration['shards']; |
| 904 int i = configuration['shard']; |
| 905 if (n >= 2) { |
| 906 int current = 0; |
| 907 // The test function given to cachedTests.filter uses the entry's index. |
| 908 cachedTests = cachedTests.filter((t) => ((++current % n) == i - 1)); |
| 909 } |
| 910 return cachedTests; |
| 911 } |
| 875 } | 912 } |
| 876 | 913 |
| 877 | 914 |
| 878 class DartcCompilationTestSuite extends StandardTestSuite { | 915 class DartcCompilationTestSuite extends StandardTestSuite { |
| 879 List<String> _testDirs; | 916 List<String> _testDirs; |
| 880 int activityCount = 0; | 917 int activityCount = 0; |
| 881 | 918 |
| 882 DartcCompilationTestSuite(Map configuration, | 919 DartcCompilationTestSuite(Map configuration, |
| 883 String suiteName, | 920 String suiteName, |
| 884 String directoryPath, | 921 String directoryPath, |
| (...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1231 * $noCrash tests are expected to be flaky but not crash | 1268 * $noCrash tests are expected to be flaky but not crash |
| 1232 * $pass tests are expected to pass | 1269 * $pass tests are expected to pass |
| 1233 * $failOk tests are expected to fail that we won't fix | 1270 * $failOk tests are expected to fail that we won't fix |
| 1234 * $fail tests are expected to fail that we should fix | 1271 * $fail tests are expected to fail that we should fix |
| 1235 * $crash tests are expected to crash that we should fix | 1272 * $crash tests are expected to crash that we should fix |
| 1236 * $timeout tests are allowed to timeout | 1273 * $timeout tests are allowed to timeout |
| 1237 """; | 1274 """; |
| 1238 print(report); | 1275 print(report); |
| 1239 } | 1276 } |
| 1240 } | 1277 } |
| OLD | NEW |