Chromium Code Reviews| Index: tools/testing/dart/test_suite.dart |
| diff --git a/tools/testing/dart/test_suite.dart b/tools/testing/dart/test_suite.dart |
| index 4bbd4f41e68941e3fa7c5691e16e3c0937fc745e..a911e9043844e09c05ad7eacb48d249ecfac80ba 100644 |
| --- a/tools/testing/dart/test_suite.dart |
| +++ b/tools/testing/dart/test_suite.dart |
| @@ -246,6 +246,16 @@ class StandardTestSuite implements TestSuite { |
| // this suite. |
| if (!testCache.containsKey(suiteName)) { |
| cachedTests = testCache[suiteName] = []; |
| + 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.
|
| + Function oldDone = doDone; |
| + doDone = () { |
| + testCache[suiteName] = shardTests(); |
| + for (var info in testCache[suiteName]) { |
| + enqueueTestCaseFromTestInformation(info); |
| + } |
| + oldDone(); |
| + }; |
| + } |
| processDirectory(); |
| } else { |
| // We rely on enqueueing completing asynchronously so use a |
| @@ -390,7 +400,10 @@ class StandardTestSuite implements TestSuite { |
| hasRuntimeErrors, |
| multitestOutcome); |
| cachedTests.add(info); |
| - enqueueTestCaseFromTestInformation(info); |
| + if (configuration['shards'] == 1) { |
| + // If we are not sharding, we queue the tests as we find them. |
| + enqueueTestCaseFromTestInformation(info); |
| + } |
| }; |
| } |
| @@ -867,6 +880,23 @@ class StandardTestSuite implements TestSuite { |
| "numStaticTypeAnnotations": numStaticTypeAnnotations, |
| "numCompileTimeAnnotations": numCompileTimeAnnotations}; |
| } |
| + |
| + /** |
| + * shardTests takes the list of tests, stored as the List<TestInformation> cachedTests, |
| + * and selects only the tests belonging to this shard. The tests are sorted by filename, |
| + * and if there are n shards and we are shard number i, only the tests at indices 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.
|
| + * i-1 modulo n are kept. |
| + */ |
| + List<TestInformation> shardTests() { |
| + cachedTests.sort((TestInformation a, TestInformation b) => a.filename.compareTo(b.filename)); |
| + int n = configuration['shards']; |
| + int i = configuration['shard']; |
| + if (n >= 2) { |
| + int current = 0; |
| + 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.
|
| + } |
| + return cachedTests; |
| + } |
| } |