Bug 1497898 - Pass the manifest file directly into wpttest.from_manifest, r=ato
authorJames Graham <james@hoppipolla.co.uk>
Fri, 16 Nov 2018 18:46:57 +0000
changeset 503256 7f54376353321e398e7389a1aa3f1165d775faf9
parent 503255 daf29e8abb1eb0f5685ed9d228afeb6b4a0c4327
child 503257 750b40bcdad7d60d10ea78f386493d962af89de1
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato
bugs1497898
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1497898 - Pass the manifest file directly into wpttest.from_manifest, r=ato Depends on D8229 Differential Revision: https://phabricator.services.mozilla.com/D8230
testing/web-platform/tests/tools/wpt/testfiles.py
testing/web-platform/tests/tools/wptrunner/wptrunner/testloader.py
testing/web-platform/tests/tools/wptrunner/wptrunner/tests/test_wpttest.py
testing/web-platform/tests/tools/wptrunner/wptrunner/wpttest.py
--- a/testing/web-platform/tests/tools/wpt/testfiles.py
+++ b/testing/web-platform/tests/tools/wpt/testfiles.py
@@ -3,17 +3,17 @@ import logging
 import os
 import re
 import subprocess
 import sys
 
 from collections import OrderedDict
 from six import iteritems
 
-from ..manifest import manifest, update
+from ..manifest import manifest
 
 here = os.path.dirname(__file__)
 wpt_root = os.path.abspath(os.path.join(here, os.pardir, os.pardir))
 
 logger = logging.getLogger()
 
 
 def get_git_cmd(repo_path):
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/testloader.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/testloader.py
@@ -1,10 +1,9 @@
 import hashlib
-import json
 import os
 import urlparse
 from abc import ABCMeta, abstractmethod
 from Queue import Empty
 from collections import defaultdict, OrderedDict, deque
 from multiprocessing import Queue
 
 import manifestinclude
@@ -460,22 +459,22 @@ class TestLoader(object):
     def test_ids(self):
         if self._test_ids is None:
             self._test_ids = []
             for test_dict in [self.disabled_tests, self.tests]:
                 for test_type in self.test_types:
                     self._test_ids += [item.id for item in test_dict[test_type]]
         return self._test_ids
 
-    def get_test(self, manifest_test, inherit_metadata, test_metadata):
+    def get_test(self, manifest_file, manifest_test, inherit_metadata, test_metadata):
         if test_metadata is not None:
             inherit_metadata.append(test_metadata)
             test_metadata = test_metadata.get_test(manifest_test.id)
 
-        return wpttest.from_manifest(manifest_test, inherit_metadata, test_metadata)
+        return wpttest.from_manifest(manifest_file, manifest_test, inherit_metadata, test_metadata)
 
     def load_dir_metadata(self, test_manifest, metadata_path, test_path):
         rv = []
         path_parts = os.path.dirname(test_path).split(os.path.sep)
         for i in xrange(len(path_parts) + 1):
             path = os.path.join(metadata_path, os.path.sep.join(path_parts[:i]), "__dir__.ini")
             if path not in self.directory_manifests:
                 self.directory_manifests[path] = manifestexpected.get_dir_manifest(path,
@@ -502,25 +501,20 @@ class TestLoader(object):
             manifests_by_url_base[manifest.url_base] = manifest
 
         if self.chunker is not None:
             manifest_items = self.chunker(manifest_items)
 
         for test_type, test_path, tests in manifest_items:
             manifest_file = manifests_by_url_base[iter(tests).next().url_base]
             metadata_path = self.manifests[manifest_file]["metadata_path"]
+
             inherit_metadata, test_metadata = self.load_metadata(manifest_file, metadata_path, test_path)
-
-            for test in iterfilter(self.meta_filters,
-                                   self.iter_wpttest(inherit_metadata, test_metadata, tests)):
-                yield test_path, test_type, test
-
-    def iter_wpttest(self, inherit_metadata, test_metadata, tests):
-        for manifest_test in tests:
-            yield self.get_test(manifest_test, inherit_metadata, test_metadata)
+            for test in tests:
+                yield test_path, test_type, self.get_test(manifest_file, test, inherit_metadata, test_metadata)
 
     def _load_tests(self):
         """Read in the tests from the manifest file and add them to a queue"""
         tests = {"enabled":defaultdict(list),
                  "disabled":defaultdict(list)}
 
         for test_path, test_type, test in self.iter_tests():
             enabled = not test.disabled()
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/tests/test_wpttest.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/tests/test_wpttest.py
@@ -55,17 +55,17 @@ def test_metadata_inherit():
         for item in [dir_ini_0, dir_ini_1]]
     test_metadata = manifestexpected.static.compile(BytesIO(test_0),
                                                     {},
                                                     data_cls_getter=manifestexpected.data_cls_getter,
                                                     test_path="a",
                                                     url_base="")
 
     test = tests[0][2].pop()
-    test_obj = wpttest.from_manifest(test, inherit_metadata, test_metadata.get_test(test.id))
+    test_obj = wpttest.from_manifest(tests, test, inherit_metadata, test_metadata.get_test(test.id))
     assert test_obj.max_assertion_count == 3
     assert test_obj.min_assertion_count == 1
     assert test_obj.prefs == {"b": "c", "c": "d"}
     assert test_obj.tags == {"a", "dir:a"}
 
 
 def test_conditional():
     tests = make_mock_manifest(("test", "a", 10), ("test", "a/b", 10),
@@ -73,17 +73,17 @@ def test_conditional():
 
     test_metadata = manifestexpected.static.compile(BytesIO(test_1),
                                                     {"os": "win"},
                                                     data_cls_getter=manifestexpected.data_cls_getter,
                                                     test_path="a",
                                                     url_base="")
 
     test = tests[1][2].pop()
-    test_obj = wpttest.from_manifest(test, [], test_metadata.get_test(test.id))
+    test_obj = wpttest.from_manifest(tests, test, [], test_metadata.get_test(test.id))
     assert test_obj.prefs == {"a": "b", "c": "d"}
     assert test_obj.expected() == "FAIL"
 
 def test_metadata_lsan_stack_depth():
     tests = make_mock_manifest(("test", "a", 10), ("test", "a/b", 10))
 
     test_metadata = manifestexpected.static.compile(BytesIO(test_2),
                                                     {},
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/wpttest.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/wpttest.py
@@ -141,17 +141,17 @@ class Test(object):
         return self.id == other.id
 
     def update_metadata(self, metadata=None):
         if metadata is None:
             metadata = {}
         return metadata
 
     @classmethod
-    def from_manifest(cls, manifest_item, inherit_metadata, test_metadata):
+    def from_manifest(cls, manifest_file, manifest_item, inherit_metadata, test_metadata):
         timeout = cls.long_timeout if manifest_item.timeout == "long" else cls.default_timeout
         protocol = "https" if hasattr(manifest_item, "https") and manifest_item.https else "http"
         return cls(manifest_item.source_file.tests_root,
                    manifest_item.url,
                    inherit_metadata,
                    test_metadata,
                    timeout=timeout,
                    path=manifest_item.source_file.path,
@@ -297,17 +297,17 @@ class TestharnessTest(Test):
         Test.__init__(self, tests_root, url, inherit_metadata, test_metadata, timeout,
                       path, protocol)
 
         self.testdriver = testdriver
         self.jsshell = jsshell
         self.scripts = scripts or []
 
     @classmethod
-    def from_manifest(cls, manifest_item, inherit_metadata, test_metadata):
+    def from_manifest(cls, manifest_file, manifest_item, inherit_metadata, test_metadata):
         timeout = cls.long_timeout if manifest_item.timeout == "long" else cls.default_timeout
         protocol = "https" if hasattr(manifest_item, "https") and manifest_item.https else "http"
         testdriver = manifest_item.testdriver if hasattr(manifest_item, "testdriver") else False
         jsshell = manifest_item.jsshell if hasattr(manifest_item, "jsshell") else False
         script_metadata = manifest_item.source_file.script_metadata or []
         scripts = [v for (k, v) in script_metadata if k == b"script"]
         return cls(manifest_item.source_file.tests_root,
                    manifest_item.url,
@@ -347,16 +347,17 @@ class ReftestTest(Test):
                 raise ValueError
 
         self.references = references
         self.viewport_size = viewport_size
         self.dpi = dpi
 
     @classmethod
     def from_manifest(cls,
+                      manifest_file,
                       manifest_test,
                       inherit_metadata,
                       test_metadata,
                       nodes=None,
                       references_seen=None):
 
         timeout = cls.long_timeout if manifest_test.timeout == "long" else cls.default_timeout
 
@@ -389,19 +390,20 @@ class ReftestTest(Test):
                     # Note that just seeing a node for the second time is not
                     # enough to detect a cycle because
                     # A != B != C != A must include C != A
                     # but A == B == A should not include the redundant B == A.
                     continue
 
             references_seen.add(comparison_key)
 
-            manifest_node = manifest_test.manifest.get_reference(ref_url)
+            manifest_node = manifest_file.get_reference(ref_url)
             if manifest_node:
-                reference = ReftestTest.from_manifest(manifest_node,
+                reference = ReftestTest.from_manifest(manifest_file,
+                                                      manifest_node,
                                                       [],
                                                       None,
                                                       nodes,
                                                       references_seen)
             else:
                 reference = ReftestTest(manifest_test.source_file.tests_root,
                                         ref_url,
                                         [],
@@ -443,11 +445,11 @@ class WdspecTest(Test):
 
 
 manifest_test_cls = {"reftest": ReftestTest,
                      "testharness": TestharnessTest,
                      "manual": ManualTest,
                      "wdspec": WdspecTest}
 
 
-def from_manifest(manifest_test, inherit_metadata, test_metadata):
+def from_manifest(manifest_file, manifest_test, inherit_metadata, test_metadata):
     test_cls = manifest_test_cls[manifest_test.item_type]
-    return test_cls.from_manifest(manifest_test, inherit_metadata, test_metadata)
+    return test_cls.from_manifest(manifest_file, manifest_test, inherit_metadata, test_metadata)