Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update html5lib tests #39158

Merged
merged 2 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions html/syntax/parsing/README
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ the tests under speculative-parsing/.
To update the generated tests, run
`wpt update-built --include html5lib speculative-parsing`.

The revision of html5lib used to generate the tests is stored in
html/tools/html5lib_revision
The revision of html5lib-tests used to generate the tests is stored in
html/tools/html5lib_tests_revision
25 changes: 25 additions & 0 deletions html/syntax/parsing/html5lib_innerHTML_template.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<title>HTML 5 Parser tests html5lib_innerHTML_template.html</title>
<meta name="timeout" content="long">
</head>
<body>
<h1>html5lib Parser Test</h1>
<div id="log"></div>
<script src="common.js"></script>
<script src="test.js"></script>
<script src="template.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var num_iframes = 8;
var order = ['64d3e0e4395745b6ea928e5f5cf888bf675a598b',];
var tests = {
"64d3e0e4395745b6ea928e5f5cf888bf675a598b":[async_test('html5lib_innerHTML_template.html 64d3e0e4395745b6ea928e5f5cf888bf675a598b'), "%3Ctemplate%3E%3Cform%3E%3Cinput%20name%3D%22q%22%3E%3C/form%3E%3Cdiv%3Esecond%3C/div%3E%3C/template%3E", "%23document%0A%7C%20%3Ctemplate%3E%0A%7C%20%20%20content%0A%7C%20%20%20%20%20%3Cform%3E%0A%7C%20%20%20%20%20%20%20%3Cinput%3E%0A%7C%20%20%20%20%20%20%20%20%20name%3D%22q%22%0A%7C%20%20%20%20%20%3Cdiv%3E%0A%7C%20%20%20%20%20%20%20%22second%22", 'template'],
}
init_tests("innerHTML");
</script>
</body>
</html>
28 changes: 28 additions & 0 deletions html/syntax/parsing/html5lib_search-element.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<title>HTML 5 Parser tests html5lib_search-element.html</title>
<meta name="timeout" content="long">
<meta name="variant" content="?run_type=uri">
<meta name="variant" content="?run_type=write">
<meta name="variant" content="?run_type=write_single">
</head>
<body>
<h1>html5lib Parser Test</h1>
<div id="log"></div>
<script src="common.js"></script>
<script src="test.js"></script>
<script src="template.js"></script>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var num_iframes = 8;
var order = ['114b9f3c8147c0ed8ef3ed1811a9da3f10d74402','2204afb9037ec886f428ab5dcead5ee9f87c65cb','5153f797fbb63a23a40d19e298aca06d53d22f7f',];
var tests = {
"114b9f3c8147c0ed8ef3ed1811a9da3f10d74402":[async_test('html5lib_search-element.html 114b9f3c8147c0ed8ef3ed1811a9da3f10d74402'), "%3C%21doctype%20html%3E%3Cp%3Efoo%3Csearch%3Ebar%3Cp%3Ebaz", "%23document%0A%7C%20%3C%21DOCTYPE%20html%3E%0A%7C%20%3Chtml%3E%0A%7C%20%20%20%3Chead%3E%0A%7C%20%20%20%3Cbody%3E%0A%7C%20%20%20%20%20%3Cp%3E%0A%7C%20%20%20%20%20%20%20%22foo%22%0A%7C%20%20%20%20%20%3Csearch%3E%0A%7C%20%20%20%20%20%20%20%22bar%22%0A%7C%20%20%20%20%20%20%20%3Cp%3E%0A%7C%20%20%20%20%20%20%20%20%20%22baz%22"],"2204afb9037ec886f428ab5dcead5ee9f87c65cb":[async_test('html5lib_search-element.html 2204afb9037ec886f428ab5dcead5ee9f87c65cb'), "%3C%21doctype%20html%3E%3Csearch%3E%3Cp%3Efoo%3C/search%3Ebar", "%23document%0A%7C%20%3C%21DOCTYPE%20html%3E%0A%7C%20%3Chtml%3E%0A%7C%20%20%20%3Chead%3E%0A%7C%20%20%20%3Cbody%3E%0A%7C%20%20%20%20%20%3Csearch%3E%0A%7C%20%20%20%20%20%20%20%3Cp%3E%0A%7C%20%20%20%20%20%20%20%20%20%22foo%22%0A%7C%20%20%20%20%20%22bar%22"],"5153f797fbb63a23a40d19e298aca06d53d22f7f":[async_test('html5lib_search-element.html 5153f797fbb63a23a40d19e298aca06d53d22f7f'), "%3C%21DOCTYPE%20html%3Exxx%3Csvg%3E%3Cx%3E%3Cg%3E%3Ca%3E%3Csearch%3E%3Cb%3E", "%23document%0A%7C%20%3C%21DOCTYPE%20html%3E%0A%7C%20%3Chtml%3E%0A%7C%20%20%20%3Chead%3E%0A%7C%20%20%20%3Cbody%3E%0A%7C%20%20%20%20%20%22xxx%22%0A%7C%20%20%20%20%20%3Csvg%20svg%3E%0A%7C%20%20%20%20%20%20%20%3Csvg%20x%3E%0A%7C%20%20%20%20%20%20%20%20%20%3Csvg%20g%3E%0A%7C%20%20%20%20%20%20%20%20%20%20%20%3Csvg%20a%3E%0A%7C%20%20%20%20%20%20%20%20%20%20%20%20%20%3Csvg%20search%3E%0A%7C%20%20%20%20%20%3Cb%3E"],
}
init_tests(get_type());
</script>
</body>
</html>
4 changes: 2 additions & 2 deletions html/syntax/parsing/html5lib_template.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions html/syntax/parsing/html5lib_tests20.html

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions html/tools/html5lib_tests_revision
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
95417e63a22e6624013558fd5a7d44d0265491b9
48 changes: 41 additions & 7 deletions html/tools/update_html5lib_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,52 @@ def get_hash(data, container=None):


class Html5libInstall:
def __init__(self, rev=None):
def __init__(self, rev=None, tests_rev=None):
self.html5lib_dir = None
self.rev = rev
self.tests_rev = tests_rev

def __enter__(self):
self.html5lib_dir = tempfile.TemporaryDirectory()
html5lib_path = self.html5lib_dir.__enter__()
subprocess.check_call(["git", "clone", "--no-checkout", "https://github.com/html5lib/html5lib-python.git", "html5lib"],
cwd=html5lib_path)
html5lib_python_path = os.path.join(html5lib_path, "html5lib")
html5lib_tests_path = os.path.join(
html5lib_python_path, "html5lib", "tests", "testdata"
)

subprocess.check_call(
[
"git",
"clone",
"--no-checkout",
"https://github.com/html5lib/html5lib-python.git",
"html5lib",
],
cwd=html5lib_path,
)

rev = self.rev if self.rev is not None else "origin/master"
subprocess.check_call(["git", "checkout", rev],
cwd=os.path.join(html5lib_path, "html5lib"))
subprocess.check_call(
["git", "checkout", rev], cwd=html5lib_python_path
)

subprocess.check_call(
[
"git",
"submodule",
"update",
"--init",
"--recursive",
],
cwd=html5lib_python_path,
)

subprocess.check_call(["pip", "install", "-e", "html5lib"], cwd=html5lib_path)
reload(site)

tests_rev = self.tests_rev if self.tests_rev is not None else "origin/master"
subprocess.check_call(["git", "checkout", tests_rev], cwd=html5lib_tests_path)

def __exit__(self, *args, **kwargs):
subprocess.call(["pip", "uninstall", "-y", "html5lib"], cwd=self.html5lib_dir.name)
self.html5lib_dir.__exit__(*args, **kwargs)
Expand Down Expand Up @@ -132,10 +163,13 @@ def main():

test_files = []
inner_html_files = []
with open(os.path.join(script_dir, "html5lib_revision"), "r") as f:
with open(os.path.join(script_dir, "html5lib_python_revision"), "r") as f:
html5lib_rev = f.read().strip()

with Html5libInstall(html5lib_rev):
with open(os.path.join(script_dir, "html5lib_tests_revision"), "r") as f:
html5lib_tests_rev = f.read().strip()

with Html5libInstall(html5lib_rev, html5lib_tests_rev):
from html5lib.tests import support

if len(sys.argv) > 2:
Expand Down