Skip to content

Commit

Permalink
import-w3c-tests should rely on <meta name="flags"> to detect CSS man…
Browse files Browse the repository at this point in the history
…ual tests

https://bugs.webkit.org/show_bug.cgi?id=186261

Patch by Frederic Wang <[email protected]> on 2018-06-04
Reviewed by Youenn Fablet.

* Scripts/webkitpy/w3c/test_parser.py:
(TestParser.is_wpt_manualtest): Add code to detect whether a file is a manual test
from its <meta name="flags"> tags. This is based on SourceFile::content_is_css_manual from
the WPT repository.
* Scripts/webkitpy/w3c/test_parser_unittest.py: Add a test to verify whether files with
<meta name="flags"> are manual or non-manual according to CSS WG rules.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@232506 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
[email protected] committed Jun 5, 2018
1 parent 60b530b commit 9c2eb2c
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 2 deletions.
14 changes: 14 additions & 0 deletions Tools/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
2018-06-04 Frederic Wang <[email protected]>

import-w3c-tests should rely on <meta name="flags"> to detect CSS manual tests
https://bugs.webkit.org/show_bug.cgi?id=186261

Reviewed by Youenn Fablet.

* Scripts/webkitpy/w3c/test_parser.py:
(TestParser.is_wpt_manualtest): Add code to detect whether a file is a manual test
from its <meta name="flags"> tags. This is based on SourceFile::content_is_css_manual from
the WPT repository.
* Scripts/webkitpy/w3c/test_parser_unittest.py: Add a test to verify whether files with
<meta name="flags"> are manual or non-manual according to CSS WG rules.

2018-06-04 Dan Bernstein <[email protected]>

Fixed building ImageDiff with the default build system in the Xcode 10 developer beta.
Expand Down
19 changes: 17 additions & 2 deletions Tools/Scripts/webkitpy/w3c/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,23 @@ def is_jstest(self):
return bool(self.test_doc.find(src=re.compile('[\'\"/]?/resources/testharness')))

def is_wpt_manualtest(self):
"""Returns whether the test is a manual test according WPT rules (i.e. file ends with -manual.htm path)."""
return self.filename.endswith('-manual.htm') or self.filename.endswith('-manual.html')
"""Returns whether the test is a manual test according WPT rules."""
# General rule for manual test i.e. file ends with -manual.htm path
# See https://web-platform-tests.org/writing-tests/manual.html#requirements-for-a-manual-test
if self.filename.endswith('-manual.htm') or self.filename.endswith('-manual.html'):
return True

# Rule specific to CSS WG manual tests i.e. rely on <meta name="flags">
# See https://web-platform-tests.org/writing-tests/css-metadata.html#requirement-flags
# For further details and discussions, see the following links:
# https://github.com/web-platform-tests/wpt/issues/5381
# https://github.com/web-platform-tests/wpt/issues/5293
for match in self.test_doc.findAll(name='meta', attrs={'name': 'flags', 'content': True}):
css_flags = set(match['content'].split())
if bool(css_flags & {"animated", "font", "history", "interact", "paged", "speech", "userstyle"}):
return True

return False

def is_slow_test(self):
return any([match.name == 'meta' and match['name'] == 'timeout' for match in self.test_doc.findAll(content='long')])
Expand Down
25 changes: 25 additions & 0 deletions Tools/Scripts/webkitpy/w3c/test_parser_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,31 @@ def test_analyze_manual_wpt_test(self):

self.assertTrue(test_info['manualtest'], 'test_info is None')

def test_analyze_css_manual_test(self):
""" Tests analyze_test() using a css manual test """

test_path = os.path.join(os.path.sep, 'some', 'madeup', 'path')
parser = TestParser(options, os.path.join(test_path, 'somefile.html'))

for content in ["", "flag1", "flag1 flag2", "flag1 flag2 flag3", "asis"]:
test_html = """
<head>
<meta name="flags" content="%s">
</head>""" % content
test_info = parser.analyze_test(test_contents=test_html)
self.assertEqual(test_info, None, 'test_info should be None')

for flag in ["animated", "font", "history", "interact", "paged", "speech", "userstyle"]:
test_html = """
<head>
<meta name="flags" content="flag1 flag2">
<meta name="flags" content="flag3 %s flag4 flag5">
<meta name="flags" content="flag6">
</head>
""" % flag
test_info = parser.analyze_test(test_contents=test_html)
self.assertTrue(test_info['manualtest'], 'test with CSS flag %s should be manual' % flag)

def test_analyze_pixel_test_all_true(self):
""" Tests analyze_test() using a test that is neither a reftest or jstest with all=False """

Expand Down

0 comments on commit 9c2eb2c

Please sign in to comment.