Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Classes and methods for enumerating and preparing tests. | 6 * Classes and methods for enumerating and preparing tests. |
| 7 * | 7 * |
| 8 * This library includes: | 8 * This library includes: |
| 9 * | 9 * |
| 10 * - Creating tests by listing all the Dart files in certain directories, | 10 * - Creating tests by listing all the Dart files in certain directories, |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 globalTemporaryDirectory = globalTempDir; | 239 globalTemporaryDirectory = globalTempDir; |
| 240 | 240 |
| 241 var filesRead = 0; | 241 var filesRead = 0; |
| 242 void statusFileRead() { | 242 void statusFileRead() { |
| 243 filesRead++; | 243 filesRead++; |
| 244 if (filesRead == statusFilePaths.length) { | 244 if (filesRead == statusFilePaths.length) { |
| 245 // Checked if we have already found and generated the tests for | 245 // Checked if we have already found and generated the tests for |
| 246 // this suite. | 246 // this suite. |
| 247 if (!testCache.containsKey(suiteName)) { | 247 if (!testCache.containsKey(suiteName)) { |
| 248 cachedTests = testCache[suiteName] = []; | 248 cachedTests = testCache[suiteName] = []; |
| 249 if (configuration['shards'] > 1) { | |
|
Mads Ager (google)
2012/03/23 23:38:20
You should add a comment about how this works for
Bill Hesse
2012/03/28 22:46:19
Done.
| |
| 250 Function oldDone = doDone; | |
| 251 doDone = () { | |
| 252 testCache[suiteName] = shardTests(); | |
| 253 for (var info in testCache[suiteName]) { | |
| 254 enqueueTestCaseFromTestInformation(info); | |
| 255 } | |
| 256 oldDone(); | |
| 257 }; | |
| 258 } | |
| 249 processDirectory(); | 259 processDirectory(); |
| 250 } else { | 260 } else { |
| 251 // We rely on enqueueing completing asynchronously so use a | 261 // We rely on enqueueing completing asynchronously so use a |
| 252 // timer to make it so. | 262 // timer to make it so. |
| 253 void enqueueCachedTests(Timer ignore) { | 263 void enqueueCachedTests(Timer ignore) { |
| 254 for (var info in testCache[suiteName]) { | 264 for (var info in testCache[suiteName]) { |
| 255 enqueueTestCaseFromTestInformation(info); | 265 enqueueTestCaseFromTestInformation(info); |
| 256 } | 266 } |
| 257 doDone(); | 267 doDone(); |
| 258 } | 268 } |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 383 Set<String> multitestOutcome = null]) { | 393 Set<String> multitestOutcome = null]) { |
| 384 // Cache the test information for each test case. | 394 // Cache the test information for each test case. |
| 385 var info = new TestInformation(filename, | 395 var info = new TestInformation(filename, |
| 386 optionsFromFile, | 396 optionsFromFile, |
| 387 isNegative, | 397 isNegative, |
| 388 isNegativeIfChecked, | 398 isNegativeIfChecked, |
| 389 hasFatalTypeErrors, | 399 hasFatalTypeErrors, |
| 390 hasRuntimeErrors, | 400 hasRuntimeErrors, |
| 391 multitestOutcome); | 401 multitestOutcome); |
| 392 cachedTests.add(info); | 402 cachedTests.add(info); |
| 393 enqueueTestCaseFromTestInformation(info); | 403 if (configuration['shards'] == 1) { |
| 404 // If we are not sharding, we queue the tests as we find them. | |
| 405 enqueueTestCaseFromTestInformation(info); | |
| 406 } | |
| 394 }; | 407 }; |
| 395 } | 408 } |
| 396 | 409 |
| 397 void processFile(String filename) { | 410 void processFile(String filename) { |
| 398 if (!isTestFile(filename)) return; | 411 if (!isTestFile(filename)) return; |
| 399 | 412 |
| 400 // Only run the tests that match the pattern. | 413 // Only run the tests that match the pattern. |
| 401 RegExp pattern = configuration['selectors'][suiteName]; | 414 RegExp pattern = configuration['selectors'][suiteName]; |
| 402 if (!pattern.hasMatch(filename)) return; | 415 if (!pattern.hasMatch(filename)) return; |
| 403 if (filename.endsWith('test_config.dart')) return; | 416 if (filename.endsWith('test_config.dart')) return; |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 860 "otherScripts": otherScripts, | 873 "otherScripts": otherScripts, |
| 861 "isMultitest": isMultitest, | 874 "isMultitest": isMultitest, |
| 862 "containsLeadingHash": containsLeadingHash, | 875 "containsLeadingHash": containsLeadingHash, |
| 863 "isolateStubs": isolateStubs, | 876 "isolateStubs": isolateStubs, |
| 864 "containsDomImport": containsDomImport, | 877 "containsDomImport": containsDomImport, |
| 865 "isLibraryDefinition": isLibraryDefinition, | 878 "isLibraryDefinition": isLibraryDefinition, |
| 866 "containsSourceOrImport": containsSourceOrImport, | 879 "containsSourceOrImport": containsSourceOrImport, |
| 867 "numStaticTypeAnnotations": numStaticTypeAnnotations, | 880 "numStaticTypeAnnotations": numStaticTypeAnnotations, |
| 868 "numCompileTimeAnnotations": numCompileTimeAnnotations}; | 881 "numCompileTimeAnnotations": numCompileTimeAnnotations}; |
| 869 } | 882 } |
| 883 | |
| 884 /** | |
| 885 * shardTests takes the list of tests, stored as the List<TestInformation> cac hedTests, | |
| 886 * and selects only the tests belonging to this shard. The tests are sorted b y filename, | |
| 887 * and if there are n shards and we are shard number i, only the tests at indi ces equal to | |
|
Bill Hesse
2012/03/23 22:33:56
Fix long lines in this function.
Bill Hesse
2012/03/28 22:46:19
Done.
| |
| 888 * i-1 modulo n are kept. | |
| 889 */ | |
| 890 List<TestInformation> shardTests() { | |
| 891 cachedTests.sort((TestInformation a, TestInformation b) => a.filename.compar eTo(b.filename)); | |
| 892 int n = configuration['shards']; | |
| 893 int i = configuration['shard']; | |
| 894 if (n >= 2) { | |
| 895 int current = 0; | |
| 896 cachedTests = cachedTests.filter((t) => ++current % n == i - 1); | |
|
Mads Ager (google)
2012/03/23 23:38:20
I would add some parenthesis here to help the read
Bill Hesse
2012/03/28 22:46:19
Done.
| |
| 897 } | |
| 898 return cachedTests; | |
| 899 } | |
| 870 } | 900 } |
| 871 | 901 |
| 872 | 902 |
| 873 class DartcCompilationTestSuite extends StandardTestSuite { | 903 class DartcCompilationTestSuite extends StandardTestSuite { |
| 874 List<String> _testDirs; | 904 List<String> _testDirs; |
| 875 int activityCount = 0; | 905 int activityCount = 0; |
| 876 | 906 |
| 877 DartcCompilationTestSuite(Map configuration, | 907 DartcCompilationTestSuite(Map configuration, |
| 878 String suiteName, | 908 String suiteName, |
| 879 String directoryPath, | 909 String directoryPath, |
| (...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1231 * $noCrash tests are expected to be flaky but not crash | 1261 * $noCrash tests are expected to be flaky but not crash |
| 1232 * $pass tests are expected to pass | 1262 * $pass tests are expected to pass |
| 1233 * $failOk tests are expected to fail that we won't fix | 1263 * $failOk tests are expected to fail that we won't fix |
| 1234 * $fail tests are expected to fail that we should fix | 1264 * $fail tests are expected to fail that we should fix |
| 1235 * $crash tests are expected to crash that we should fix | 1265 * $crash tests are expected to crash that we should fix |
| 1236 * $timeout tests are allowed to timeout | 1266 * $timeout tests are allowed to timeout |
| 1237 """; | 1267 """; |
| 1238 print(report); | 1268 print(report); |
| 1239 } | 1269 } |
| 1240 } | 1270 } |
| OLD | NEW |