Skip to content

Commit

Permalink
[wptrunner] Add testdriver flag to non-testharness manifest items
Browse files Browse the repository at this point in the history
This will let wptrunner gracefully skip testdriver tests if the executor
doesn't support them.
  • Loading branch information
jonathan-j-lee committed Oct 5, 2024
1 parent e0532a5 commit 7568d4c
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
18 changes: 17 additions & 1 deletion tools/manifest/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def pac(self) -> Optional[Text]:
return self._extras.get("pac")

@property
def testdriver(self) -> Optional[Text]:
def testdriver(self) -> Optional[bool]:
return self._extras.get("testdriver")

@property
Expand Down Expand Up @@ -240,6 +240,10 @@ def fuzzy(self) -> Fuzzy:
rv[key] = v
return rv

@property
def testdriver(self) -> Optional[bool]:
return self._extras.get("testdriver")

def to_json(self) -> Tuple[Optional[Text], List[Tuple[Text, Text]], Dict[Text, Any]]: # type: ignore
rel_url = None if self._url == self.path else self._url
rv: Tuple[Optional[Text], List[Tuple[Text, Text]], Dict[Text, Any]] = (rel_url, self.references, {})
Expand All @@ -252,6 +256,8 @@ def to_json(self) -> Tuple[Optional[Text], List[Tuple[Text, Text]], Dict[Text, A
extras["dpi"] = self.dpi
if self.fuzzy:
extras["fuzzy"] = list(self.fuzzy.items())
if self.testdriver:
extras["testdriver"] = self.testdriver
return rv

@classmethod
Expand Down Expand Up @@ -315,6 +321,16 @@ class CrashTest(URLManifestItem):
def timeout(self) -> Optional[Text]:
return None

@property
def testdriver(self) -> Optional[bool]:
return self._extras.get("testdriver")

def to_json(self): # type: ignore
rel_url, extras = super().to_json()
if self.testdriver:
extras["testdriver"] = self.testdriver
return rel_url, extras


class WebDriverSpecTest(URLManifestItem):
__slots__ = ()
Expand Down
7 changes: 5 additions & 2 deletions tools/manifest/sourcefile.py
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,8 @@ def manifest_items(self) -> Tuple[Text, List[ManifestItem]]:
self.tests_root,
self.rel_path,
self.url_base,
self.rel_url
self.rel_url,
testdriver=self.has_testdriver,
)]

elif self.name_is_print_reftest:
Expand All @@ -946,6 +947,7 @@ def manifest_items(self) -> Tuple[Text, List[ManifestItem]]:
viewport_size=self.viewport_size,
fuzzy=self.fuzzy,
page_ranges=self.page_ranges,
testdriver=self.has_testdriver,
)]

elif self.name_is_multi_global:
Expand Down Expand Up @@ -1046,7 +1048,8 @@ def manifest_items(self) -> Tuple[Text, List[ManifestItem]]:
timeout=self.timeout,
viewport_size=self.viewport_size,
dpi=self.dpi,
fuzzy=self.fuzzy
fuzzy=self.fuzzy,
testdriver=self.has_testdriver,
))

elif self.content_is_css_visual and not self.name_is_reference:
Expand Down
26 changes: 26 additions & 0 deletions tools/manifest/tests/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,29 @@ def test_manifest_spec_to_json():
]}},
}
}


@pytest.mark.parametrize("testdriver,expected_extra", [
(True, {"testdriver": True}),
# Don't bloat the manifest with the `testdriver=False` default.
(False, {}),
])
def test_dump_testdriver(testdriver, expected_extra):
m = manifest.Manifest("")
source_file = SourceFileWithTest("a" + os.path.sep + "b", "0"*40, item.RefTest,
testdriver=testdriver)

tree, sourcefile_mock = tree_and_sourcefile_mocks([(source_file, None, True)])
with mock.patch("tools.manifest.manifest.SourceFile", side_effect=sourcefile_mock):
assert m.update(tree) is True

assert m.to_json() == {
'version': 8,
'url_base': '/',
'items': {
'reftest': {'a': {'b': [
'0000000000000000000000000000000000000000',
(None, [], expected_extra)
]}},
}
}

0 comments on commit 7568d4c

Please sign in to comment.