From 5909eb76843e5a020a9498ab32fcefd441e4840e Mon Sep 17 00:00:00 2001 From: atbrakhi Date: Wed, 27 Aug 2025 11:14:21 +0200 Subject: [PATCH] devtools: Use correct servoshell path on Windows (#38938) When we landed #38614, the devtools tests consistently failed on GitHub-hosted Windows builds, because we were hardcoding the target directory. This patch fixes that by taking the `CARGO_TARGET_DIR` into account. - before: `[D:\a\servo\servo\]target/release/servo` - after: `C:\a\servo\servo\target\release\servo.exe` Testing (cherry picked onto #38614 so it runs in CI): - GitHub-hosted, before: - GitHub-hosted, after: - self-hosted, after: Fixes: part of #38658 --------- Signed-off-by: atbrakhi Co-authored-by: Delan Azabani --- python/servo/devtools_tests.py | 12 ++++-------- python/servo/testing_commands.py | 6 +++--- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/python/servo/devtools_tests.py b/python/servo/devtools_tests.py index 5cb1debbbd0..159bd21c3ba 100644 --- a/python/servo/devtools_tests.py +++ b/python/servo/devtools_tests.py @@ -28,8 +28,6 @@ from threading import Thread from typing import Any, Optional import unittest -from servo.command_base import BuildType - # Set this to true to log requests in the internal web servers. LOG_REQUESTS = False @@ -118,7 +116,7 @@ class Devtools: class DevtoolsTests(unittest.IsolatedAsyncioTestCase): # /path/to/servo/python/servo script_path = None - build_type: Optional[BuildType] = None + servo_binary: Optional[str] = None base_urls = None web_servers = None web_server_threads = None @@ -728,9 +726,7 @@ class DevtoolsTests(unittest.IsolatedAsyncioTestCase): os.environ["RUST_LOG"] = "error,devtools=warn" # Run servoshell. - self.servoshell = subprocess.Popen( - [f"target/{self.build_type.directory_name()}/servo", "--headless", "--devtools=6080", url] - ) + self.servoshell = subprocess.Popen([f"{DevtoolsTests.servo_binary}", "--headless", "--devtools=6080", url]) sleep_per_try = 1 / 8 # seconds remaining_tries = 5 / sleep_per_try # 5 seconds @@ -900,9 +896,9 @@ class DevtoolsTests(unittest.IsolatedAsyncioTestCase): return os.path.join(DevtoolsTests.script_path, os.path.join("devtools_tests", path)) -def run_tests(script_path, build_type: BuildType, test_names: list[str]): +def run_tests(script_path, servo_binary: str, test_names: list[str]): DevtoolsTests.script_path = script_path - DevtoolsTests.build_type = build_type + DevtoolsTests.servo_binary = servo_binary verbosity = 1 if logging.getLogger().level >= logging.WARN else 2 loader = unittest.TestLoader() if test_names: diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 8ee013de984..216f429e326 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -378,10 +378,10 @@ class MachCommands(CommandBase): @Command("test-devtools", description="Run tests for devtools.", category="testing") @CommandArgument("test_names", nargs=argparse.REMAINDER, help="Only run tests that match these patterns") - @CommandBase.common_command_arguments(build_type=True) - def test_devtools(self, build_type: BuildType, test_names: list[str], **kwargs: Any) -> int: + @CommandBase.common_command_arguments(binary_selection=True) + def test_devtools(self, servo_binary: str, test_names: list[str], **kwargs: Any) -> int: print("Running devtools tests...") - passed = servo.devtools_tests.run_tests(SCRIPT_PATH, build_type, test_names) + passed = servo.devtools_tests.run_tests(SCRIPT_PATH, servo_binary, test_names) return 0 if passed else 1 @Command(