From 173b6f183c6db86c68eb430b06a548f9e47264dc Mon Sep 17 00:00:00 2001 From: Mukilan Thiyagarajan Date: Tue, 27 Aug 2024 13:34:12 +0530 Subject: [PATCH] wpt: check for wpt-prefs.json in "./servo" sub-directory (#33202) The current working directory when running on WPT runners is not the folder with the servo binary, but a parent folder into which the servo nightly tar is extracted. This means the binary is `$PWD/servo/servo` and resources directory in in `$PWD/servo/resources`, so the current hardcoded relative path `resources/wpt-prefs.json` will not work on WPT runners. This is causing crashes in WPT runner: https://github.com/web-platform-tests/wpt/runs/29284407168 https://community-tc.services.mozilla.com/tasks/J7MqNwJGQRSkIWlvB5ktPQ/runs/0/logs/live/public/logs/live.log Signed-off-by: Mukilan Thiyagarajan --- tests/wpt/meta/MANIFEST.json | 2 +- .../wptrunner/executors/executorservo.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/tests/wpt/meta/MANIFEST.json b/tests/wpt/meta/MANIFEST.json index 71712e32821..c62a5120318 100644 --- a/tests/wpt/meta/MANIFEST.json +++ b/tests/wpt/meta/MANIFEST.json @@ -490288,7 +490288,7 @@ [] ], "executorservo.py": [ - "c23f7632c9ef5f0acbdbb569db41f741ccf9de89", + "90251c1e4c6b6ffd150184005466aecdc76d180d", [] ], "executorservodriver.py": [ diff --git a/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py b/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py index c23f7632c9e..90251c1e4c6 100644 --- a/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py +++ b/tests/wpt/tests/tools/wptrunner/wptrunner/executors/executorservo.py @@ -38,6 +38,8 @@ class ServoExecutor(ProcessTestExecutor): self.environment = {} self.protocol = ConnectionlessProtocol(self, browser) + self.wpt_prefs_path = self.find_wpt_prefs() + hosts_fd, self.hosts_path = tempfile.mkstemp() with os.fdopen(hosts_fd, "w") as f: f.write(make_hosts_file(server_config, "127.0.0.1")) @@ -64,6 +66,19 @@ class ServoExecutor(ProcessTestExecutor): else: self.logger.process_output(self.proc.pid, line, " ".join(self.command), self.test.url) + def find_wpt_prefs(self): + default_path = os.path.join("resources", "wpt-prefs.json") + # The cwd is the servo repo for `./mach test-wpt`, but on WPT runners + # it is the virtual environment where the nightly is extracted. In the + # latter case, the cwd has the `servo` folder inside which we find the + # binary and the 'resources' directory. + for dir in [".", "./servo"]: + candidate = os.path.abspath(os.path.join(dir, default_path)) + if os.path.isfile(candidate): + return candidate + self.logger.error("Unable to find wpt-prefs.json") + return default_path + def build_servo_command(self, test, extra_args=None, debug_opts="replace-surrogates"): args = [ "--hard-fail", "-u", "Servo/wptrunner", @@ -78,7 +93,7 @@ class ServoExecutor(ProcessTestExecutor): args += ["--user-stylesheet", stylesheet] for pref, value in self.environment.get('prefs', {}).items(): args += ["--pref", f"{pref}={value}"] - args += ["--prefs-file", "resources/wpt-prefs.json"] + args += ["--prefs-file", self.wpt_prefs_path] if self.browser.ca_certificate_path: args += ["--certificate-path", self.browser.ca_certificate_path] if extra_args: