Bug 1474581 - Add support for external scripts in wpt .any.js tests in jstests harness; r=jgraham
authorMs2ger <Ms2ger@igalia.com>
Wed, 11 Jul 2018 17:52:37 +0200
changeset 426358 396805ee5355ec5909d856975019004d8d3a6a17
parent 426357 9d11c83f1d68ad7915d7bed042347c47bd5d54c1
child 426359 6085b77ada2767a77a1fb9fa0bd9032855cfad10
push id34271
push userapavel@mozilla.com
push dateThu, 12 Jul 2018 21:52:15 +0000
treeherdermozilla-central@96c61b1dd0a1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgraham
bugs1474581
milestone63.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 1474581 - Add support for external scripts in wpt .any.js tests in jstests harness; r=jgraham
js/src/tests/jstests.py
testing/web-platform/tests/tools/wptrunner/wptrunner/wpttest.py
--- a/js/src/tests/jstests.py
+++ b/js/src/tests/jstests.py
@@ -364,18 +364,29 @@ def load_wpt_tests(requested_paths, excl
                                    run_info,
                                    manifest_filters=[path_filter])
 
     extra_helper_paths = [
         os.path.join(wpt, "resources", "testharness.js"),
         os.path.join(here, "testharnessreport.js"),
     ]
 
+    def resolve(test_path, script):
+        if script.startswith("/"):
+            return os.path.join(wpt, script[1:])
+
+        return os.path.join(test_path, script)
+
     return [
-        RefTestCase(wpt, test_path, extra_helper_paths=extra_helper_paths, wpt=test)
+        RefTestCase(
+            wpt,
+            test_path,
+            extra_helper_paths=extra_helper_paths + [resolve(test_path, s) for s in test.scripts],
+            wpt=test
+        )
         for test_path, test_type, test in loader.iter_tests()
     ]
 
 
 def load_tests(options, requested_paths, excluded_paths):
     """
     Returns a tuple: (test_count, test_gen)
         test_count: [int] Number of tests that will be in test_gen
--- a/testing/web-platform/tests/tools/wptrunner/wptrunner/wpttest.py
+++ b/testing/web-platform/tests/tools/wptrunner/wptrunner/wpttest.py
@@ -260,38 +260,42 @@ class Test(object):
 
 class TestharnessTest(Test):
     result_cls = TestharnessResult
     subtest_result_cls = TestharnessSubtestResult
     test_type = "testharness"
 
     def __init__(self, tests_root, url, inherit_metadata, test_metadata,
                  timeout=None, path=None, protocol="http", testdriver=False,
-                 jsshell=False):
+                 jsshell=False, scripts=None):
         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):
         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,
                    inherit_metadata,
                    test_metadata,
                    timeout=timeout,
                    path=manifest_item.source_file.path,
                    protocol=protocol,
                    testdriver=testdriver,
-                   jsshell=jsshell)
+                   jsshell=jsshell,
+                   scripts=scripts)
 
     @property
     def id(self):
         return self.url
 
 
 class ManualTest(Test):
     test_type = "manual"