From d7416f730812a249dfb3273cbee6c5f8debe2f39 Mon Sep 17 00:00:00 2001 From: Sam Sneddon Date: Tue, 26 Feb 2019 15:54:04 +0000 Subject: [PATCH] Fix TestharnessTest to have a correct meta_key --- tools/manifest/item.py | 5 ++++- tools/manifest/tests/test_item.py | 27 ++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/tools/manifest/item.py b/tools/manifest/item.py index 2a68f070174ed3..c06daee3e24f07 100644 --- a/tools/manifest/item.py +++ b/tools/manifest/item.py @@ -129,7 +129,10 @@ def script_metadata(self): return self._source_file.script_metadata def meta_key(self): - return (self.timeout, self.testdriver) + script_metadata = self.script_metadata + if script_metadata is not None: + script_metadata = tuple(tuple(x) for x in script_metadata) + return (self.timeout, self.testdriver, self.jsshell, script_metadata) def to_json(self): rv = URLManifestItem.to_json(self) diff --git a/tools/manifest/tests/test_item.py b/tools/manifest/tests/test_item.py index a73d46be68579f..e68b6cec41b167 100644 --- a/tools/manifest/tests/test_item.py +++ b/tools/manifest/tests/test_item.py @@ -1,6 +1,6 @@ import pytest -from ..item import URLManifestItem +from ..item import URLManifestItem, TestharnessTest @pytest.mark.parametrize("path", [ @@ -39,3 +39,28 @@ def test_url_not_https(path): m = URLManifestItem("/foobar", "/" + path, "/", "/foo.bar/" + path) assert m.https is False + + +def test_testharness_meta_key_includes_jsshell(): + a = TestharnessTest("/foobar", "/foo", "/foo.bar", "/foo.bar/foo", + jsshell=False, script_metadata=[]) + b = TestharnessTest("/foobar", "/foo", "/foo.bar", "/foo.bar/foo", + jsshell=True, script_metadata=[]) + + assert a.meta_key() != b.meta_key() + + +@pytest.mark.parametrize("script_metadata", [ + None, + [], + [('script', '/resources/WebIDLParser.js'), ('script', '/resources/idlharness.js')], + [[u'script', u'/resources/WebIDLParser.js'], [u'script', u'/resources/idlharness.js']], +]) +def test_testharness_hashable_script_metadata(script_metadata): + a = TestharnessTest("/", + "BackgroundSync/interfaces.https.any.js", + "/", + "/BackgroundSync/interfaces.https.any.js", + script_metadata=script_metadata) + + assert hash(a) is not None