Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(235)

Unified Diff: tools/testing/dart/test_suite.dart

Issue 9834070: Shard tests run by test.dart, so they can be distributed to multiple machines. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
+ }
}
« tools/testing/dart/test_options.dart ('K') | « tools/testing/dart/test_options.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698