aboutsummaryrefslogtreecommitdiffstats
path: root/python
diff options
context:
space:
mode:
authorMartin Robinson <mrobinson@igalia.com>2023-01-13 10:39:06 +0100
committerMartin Robinson <mrobinson@igalia.com>2023-01-13 16:23:52 +0100
commit42c3d05d2bf8d301efaa90e1312a24cd95119d9b (patch)
tree6b4989b48be2ae0b1e768f1f174b06b15c282a52 /python
parent633f14df119b021a108d379cdcce058383e372e6 (diff)
downloadservo-42c3d05d2bf8d301efaa90e1312a24cd95119d9b.tar.gz
servo-42c3d05d2bf8d301efaa90e1312a24cd95119d9b.zip
Simplify Python code for running WPT tests
Combine `run.py` and `update.py` into `servowpt.py` in order to allow them to share code. Import them directly into the mach script to avoid having to call `compile` and `exec` on the code. This makes it clearer how they are executed. In addition, move all of the setup into `setupwpt.py` to avoid differences between tests executed via mach and not. Finally, be more ambitious when detecting the build to use. If none was specified, try to use the one that exists between "release" and "debug."
Diffstat (limited to 'python')
-rw-r--r--python/servo/testing_commands.py52
1 files changed, 7 insertions, 45 deletions
diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py
index 483f9c7c2c9..c98311ad9c5 100644
--- a/python/servo/testing_commands.py
+++ b/python/servo/testing_commands.py
@@ -427,10 +427,10 @@ class MachCommands(CommandBase):
def _test_wpt(self, android=False, **kwargs):
self.set_run_env(android)
- hosts_file_path = path.join(self.context.topdir, 'tests', 'wpt', 'hosts')
- os.environ["HOST_FILE"] = hosts_file_path
- run_file = path.abspath(path.join(self.context.topdir, "tests", "wpt", "run.py"))
- return self.wptrunner(run_file, **kwargs)
+
+ sys.path.insert(0, os.path.join(PROJECT_TOPLEVEL_PATH, 'tests', 'wpt'))
+ import servowpt
+ return servowpt.run_tests(**kwargs)
# Helper to ensure all specified paths are handled, otherwise dispatch to appropriate test suite.
def run_test_list_or_dispatch(self, requested_paths, correct_suite, correct_function, **kwargs):
@@ -448,42 +448,6 @@ class MachCommands(CommandBase):
# Dispatch each test to the correct suite via test()
Registrar.dispatch("test", context=self.context, params=requested_paths)
- # Helper for test_css and test_wpt:
- def wptrunner(self, run_file, **kwargs):
- # By default, Rayon selects the number of worker threads
- # based on the available CPU count. This doesn't work very
- # well when running tests on CI, since we run so many
- # Servo processes in parallel. The result is a lot of
- # extra timeouts. Instead, force Rayon to assume we are
- # running on a 2 CPU environment.
- os.environ['RAYON_RS_NUM_CPUS'] = "2"
-
- os.environ["RUST_BACKTRACE"] = "1"
- kwargs["debug"] = not kwargs["release"]
- if kwargs.pop("rr_chaos"):
- kwargs["debugger"] = "rr"
- kwargs["debugger_args"] = "record --chaos"
- kwargs["repeat_until_unexpected"] = True
- # TODO: Delete rr traces from green test runs?
- prefs = kwargs.pop("prefs")
- if prefs:
- binary_args = []
- for pref in prefs:
- binary_args.append("--pref=" + pref)
- kwargs["binary_args"] = binary_args
-
- if not kwargs.get('no_default_test_types'):
- test_types = {
- "servo": ["testharness", "reftest", "wdspec"],
- "servodriver": ["testharness", "reftest"],
- }
- product = kwargs.get("product") or "servo"
- kwargs["test_types"] = test_types[product]
-
- run_globals = {"__file__": run_file}
- exec(compile(open(run_file).read(), run_file, 'exec'), run_globals)
- return run_globals["run_tests"](**kwargs)
-
@Command('update-manifest',
description='Run test-wpt --manifest-update SKIP_TESTS to regenerate MANIFEST.json',
category='testing',
@@ -509,16 +473,14 @@ class MachCommands(CommandBase):
category='testing',
parser=updatecommandline.create_parser())
def update_wpt(self, **kwargs):
- run_file = path.abspath(path.join("tests", "wpt", "update.py"))
patch = kwargs.get("patch", False)
-
if not patch and kwargs["sync"]:
print("Are you sure you don't want a patch?")
return 1
- run_globals = {"__file__": run_file}
- exec(compile(open(run_file).read(), run_file, 'exec'), run_globals)
- return run_globals["update_tests"](**kwargs)
+ sys.path.insert(0, os.path.join(PROJECT_TOPLEVEL_PATH, 'tests', 'wpt'))
+ import servowpt
+ return servowpt.update_tests(**kwargs)
@Command('filter-intermittents',
description='Given a WPT error summary file, filter out intermittents and other cruft.',