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

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

Issue 9927001: Use string hash for sharding tests instead of using an index in a sorted list. (Closed) Base URL: http://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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/testing/dart/test_suite.dart
===================================================================
--- tools/testing/dart/test_suite.dart (revision 5977)
+++ tools/testing/dart/test_suite.dart (working copy)
@@ -245,22 +245,6 @@
// this suite.
if (!testCache.containsKey(suiteName)) {
cachedTests = testCache[suiteName] = [];
- if (configuration['shards'] > 1) {
- // If we are sharding tests, we do not enqueue them as they are
- // found in the directory listing. We add all the tests to the
- // testCache, then delete all but this shard's tests from the
- // cache. The doDone function then enqueues the tests from the
- // cache, and other configurations also use the shard from the
- // cache.
- 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
@@ -396,6 +380,14 @@
bool hasFatalTypeErrors = false,
bool hasRuntimeErrors = false,
Set<String> multitestOutcome = null]) {
+ int shards = configuration['shards'];
+ if (shards > 1) {
+ int shard = configuration['shard'];
+ if (filename.hashCode() % shards != shard -1) {
+ return;
+ }
+ }
+
// Cache the test information for each test case.
var info = new TestInformation(filename,
optionsFromFile,
@@ -405,10 +397,7 @@
hasRuntimeErrors,
multitestOutcome);
cachedTests.add(info);
- if (configuration['shards'] == 1) {
- // If we are not sharding, we queue the tests as we find them.
- enqueueTestCaseFromTestInformation(info);
- }
+ enqueueTestCaseFromTestInformation(info);
};
}
@@ -891,24 +880,6 @@
"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 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;
- // The test function given to cachedTests.filter uses the entry's index.
- cachedTests = cachedTests.filter((t) => ((++current % n) == i - 1));
- }
- return cachedTests;
- }
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698