Add run_webgpu_cts.py wrapper script
This CL adds a wrapper script around run_web_tests.py for running
the WebGPU CTS. The CTS can understand some test expectations directly, and
this script will be updated in future patches to pass some of the expectations
for run_web_tests.py to the CTS Javascript harness.
This CL also moves blink/tools/extract_expectation_names.py to
third_party/webgpu-cts/scripts because it is used exclusively for WebGPU CTS
variant generation.
Bug: chromium:1186320
Change-Id: I3d2578c0dd42744912fdc6621eaef9cdb54b8234
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2783224
Reviewed-by: Corentin Wallez <[email protected]>
Reviewed-by: Dirk Pranke <[email protected]>
Commit-Queue: Austin Eng <[email protected]>
Cr-Commit-Position: refs/heads/master@{#866153}
diff --git a/BUILD.gn b/BUILD.gn
index 881261b8..9ce277c4 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -1220,16 +1220,22 @@
# This target differs from :blink_web_tests in that it uses the same
# test harness and a few additional flags but, more importantly, only runs
# the web_tests/wpt_internal/webgpu tests, so it doesn't have a data
- # dependency on the whole web_test directory.
+ # dependency on the whole web_test directory. run_webgpu_cts.py is a wrapper
+ # script around run_web_tests.py which performs additional setup for running
+ # the WebGPU CTS.
script = _common_web_test_script
- args =
- _common_web_test_args + [
- "--additional-driver-flag=--enable-unsafe-webgpu",
- "--ignore-default-expectations",
- "--additional-expectations",
- "@WrappedPath(../../third_party/blink/web_tests/WebGPUExpectations)",
- "--isolated-script-test-filter=wpt_internal/webgpu/*",
- ]
+
+ # Add run_webgpu_cts.py and remove run_web_tests.py from _common_web_test_args
+ args = [ "@WrappedPath(" +
+ rebase_path("//third_party/blink/tools/run_webgpu_cts.py",
+ root_build_dir) + ")" ] + _common_web_test_args -
+ [ _common_web_test_args[0] ]
+ args += [
+ "--webgpu-cts-expectations",
+ "@WrappedPath(../../third_party/blink/web_tests/WebGPUExpectations)",
+ "--additional-driver-flag=--enable-unsafe-webgpu",
+ "--isolated-script-test-filter=wpt_internal/webgpu/*",
+ ]
data_deps = [
":blink_web_tests_support_data",
@@ -1238,6 +1244,7 @@
data = [
"//third_party/blink/web_tests/WebGPUExpectations",
"//third_party/blink/web_tests/external/wpt/webgpu/",
+ "//third_party/webgpu-cts/scripts/",
]
}
diff --git a/testing/scripts/run_isolated_script_test.py b/testing/scripts/run_isolated_script_test.py
index 09b99d5..e7b98dc 100755
--- a/testing/scripts/run_isolated_script_test.py
+++ b/testing/scripts/run_isolated_script_test.py
@@ -48,7 +48,7 @@
# Some harnesses understand the --isolated-script-test arguments
# directly and prefer that they be passed through.
-KNOWN_ISOLATED_SCRIPT_TEST_RUNNERS = {'run_web_tests.py'}
+KNOWN_ISOLATED_SCRIPT_TEST_RUNNERS = {'run_web_tests.py', 'run_webgpu_cts.py'}
# Known typ test runners this script wraps. They need a different argument name
diff --git a/third_party/blink/tools/run_webgpu_cts.bat b/third_party/blink/tools/run_webgpu_cts.bat
new file mode 100755
index 0000000..fa276832
--- /dev/null
+++ b/third_party/blink/tools/run_webgpu_cts.bat
@@ -0,0 +1,6 @@
+@echo off
+:: Copyright 2021 The Chromium Authors. All rights reserved.
+:: Use of this source code is governed by a BSD-style license that can be
+:: found in the LICENSE file.
+
+vpython %~dp0\run_webgpu_cts.py %*
\ No newline at end of file
diff --git a/third_party/blink/tools/run_webgpu_cts.py b/third_party/blink/tools/run_webgpu_cts.py
new file mode 100755
index 0000000..2e3023b
--- /dev/null
+++ b/third_party/blink/tools/run_webgpu_cts.py
@@ -0,0 +1,9 @@
+#!/usr/bin/env vpython
+# Copyright 2021 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from blinkpy.common import multiprocessing_bootstrap
+
+multiprocessing_bootstrap.run('..', '..', 'webgpu-cts', 'scripts',
+ 'run_webgpu_cts.py')
diff --git a/third_party/blink/web_tests/webgpu/regenerate_internal_cts_html.sh b/third_party/blink/web_tests/webgpu/regenerate_internal_cts_html.sh
index acd2fed3..532f9e1 100755
--- a/third_party/blink/web_tests/webgpu/regenerate_internal_cts_html.sh
+++ b/third_party/blink/web_tests/webgpu/regenerate_internal_cts_html.sh
@@ -24,12 +24,10 @@
trap "{ rm -f $expectations; }" EXIT
echo $expectations
-pushd third_party/blink > /dev/null
- echo 'Extracting expectation names...'
- tools/extract_expectation_names.py web_tests/WebGPUExpectations > $expectations
-
-popd > /dev/null
+echo 'Extracting expectation names...'
+third_party/webgpu-cts/scripts/extract_expectation_names_for_variant_generation.py \
+ third_party/blink/web_tests/WebGPUExpectations > $expectations
pushd third_party/webgpu-cts/src > /dev/null
diff --git a/third_party/blink/tools/extract_expectation_names.py b/third_party/webgpu-cts/scripts/extract_expectation_names_for_variant_generation.py
similarity index 66%
rename from third_party/blink/tools/extract_expectation_names.py
rename to third_party/webgpu-cts/scripts/extract_expectation_names_for_variant_generation.py
index 6268ec5..2393a90 100755
--- a/third_party/blink/tools/extract_expectation_names.py
+++ b/third_party/webgpu-cts/scripts/extract_expectation_names_for_variant_generation.py
@@ -7,22 +7,25 @@
# Given an expectations file (e.g. web_tests/WebGPUExpectations), extracts only
# the test name from each expectation (e.g. wpt_internal/webgpu/cts.html?...).
-from blinkpy.common import path_finder
+import sys
+from os import path as os_path
+
+try:
+ old_sys_path = sys.path
+ third_party_dir = os_path.dirname(
+ os_path.dirname(os_path.dirname(os_path.abspath(__file__))))
+ sys.path = old_sys_path + [os_path.join(third_party_dir, 'blink', 'tools')]
+
+ from blinkpy.common import path_finder
+finally:
+ sys.path = old_sys_path
path_finder.add_typ_dir_to_sys_path()
from typ.expectations_parser import TaggedTestListParser
-import sys
-
-
-class StubPort(object):
- def is_wpt_test(name):
- return False
-
filename = sys.argv[1]
with open(filename) as f:
- port = StubPort()
parser = TaggedTestListParser(f.read())
for test_expectation in parser.expectations:
if test_expectation.test:
diff --git a/third_party/webgpu-cts/scripts/run_webgpu_cts.py b/third_party/webgpu-cts/scripts/run_webgpu_cts.py
new file mode 100644
index 0000000..e0aa730
--- /dev/null
+++ b/third_party/webgpu-cts/scripts/run_webgpu_cts.py
@@ -0,0 +1,32 @@
+# Copyright 2021 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import argparse
+import sys
+
+# This script is run via //third_party/blink/tools/run_webgpu_cts.py which
+# adds blinkpy to the Python path.
+from blinkpy.web_tests import run_web_tests
+
+
+def main(args, stderr):
+ parser = argparse.ArgumentParser(
+ description=
+ 'Performs additional setup for running the WebGPU CTS, '
+ 'then forward arguments to run_web_tests.py.'
+ )
+ parser.add_argument('--webgpu-cts-expectations', required=True)
+
+ options, rest_args = parser.parse_known_args(args)
+
+ forwarded_args = rest_args + [
+ '--ignore-default-expectations', '--additional-expectations',
+ options.webgpu_cts_expectations
+ ]
+
+ run_web_tests.main(forwarded_args, stderr)
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:], sys.stderr))