Bug 1305877 - Hash directory of test path, not full path; r?jgraham draft
authorGregory Szorc <gps@mozilla.com>
Thu, 29 Sep 2016 14:42:50 -0700
changeset 419186 a5858576decc3b2f7e122c3d3c428af4cfb59e3b
parent 419185 5857432b28a0cb6d6eb1cdfafe0a9ed377b37e08
child 419187 dec324207ac1065d6caedaf0bfc5fe89ee5bc405
child 419665 f6f5a8b8e26cda1dabce3ae2d4094866b56d7b43
push id30877
push userbmo:gps@mozilla.com
push dateThu, 29 Sep 2016 21:44:46 +0000
reviewersjgraham
bugs1305877
milestone52.0a1
Bug 1305877 - Hash directory of test path, not full path; r?jgraham Per discussion in the bug, we want automation to behave like local development mode with regards to running tests in a directory. That means we want all tests in a directory to be executed together. Hashing the directory instead of the full filename ensures that tests in the same directory end up in the same chunk. This will likely make slow directories contribute to higher variance in chunk execution times. But that's a compromise we're willing to live with at this time. MozReview-Commit-ID: GU25o5uHfQY
testing/web-platform/harness/wptrunner/testloader.py
--- a/testing/web-platform/harness/wptrunner/testloader.py
+++ b/testing/web-platform/harness/wptrunner/testloader.py
@@ -41,17 +41,19 @@ class Unchunked(TestChunker):
         for item in manifest:
             yield item
 
 
 class HashChunker(TestChunker):
     def __call__(self, manifest):
         chunk_index = self.chunk_number - 1
         for test_path, tests in manifest:
-            h = int(hashlib.md5(test_path).hexdigest(), 16)
+            # We hash the directory of the test so all tests in the same
+            # directory end up in the same chunk.
+            h = int(hashlib.md5(os.path.dirname(test_path)).hexdigest(), 16)
             if h % self.total_chunks == chunk_index:
                 yield test_path, tests
 
 
 class EqualTimeChunker(TestChunker):
     def _group_by_directory(self, manifest_items):
         """Split the list of manifest items into a ordered dict that groups tests in
         so that anything in the same subdirectory beyond a depth of 3 is in the same