Devtools: make mach test-devtools use BuildType (#37548)

`mach test-devtools` was previously hard-coded to using the release
build, which is confusing and different from how the rest of mach works
(e.g. `mach build`, `mach run`). This patch makes `mach test-devtools`
run with the debug build by default, or the other builds with
`--release` or `--profile`.

Testing: this patch directly affects our devtools tests
Fixes: many hours of head scratching

Signed-off-by: Delan Azabani <dazabani@igalia.com>
Co-authored-by: atbrakhi <atbrakhi@igalia.com>
This commit is contained in:
shuppy 2025-06-19 18:09:50 +10:00 committed by GitHub
parent 55730e99df
commit fd1255932b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View file

@ -24,6 +24,7 @@ from threading import Thread
from typing import Optional from typing import Optional
import unittest import unittest
from servo.command_base import BuildType
# Set this to true to log requests in the internal web servers. # Set this to true to log requests in the internal web servers.
LOG_REQUESTS = False LOG_REQUESTS = False
@ -32,6 +33,7 @@ LOG_REQUESTS = False
class DevtoolsTests(unittest.IsolatedAsyncioTestCase): class DevtoolsTests(unittest.IsolatedAsyncioTestCase):
# /path/to/servo/python/servo # /path/to/servo/python/servo
script_path = None script_path = None
build_type: Optional[BuildType] = None
def __init__(self, methodName="runTest"): def __init__(self, methodName="runTest"):
super().__init__(methodName) super().__init__(methodName)
@ -136,7 +138,7 @@ class DevtoolsTests(unittest.IsolatedAsyncioTestCase):
# Run servoshell. # Run servoshell.
if url is None: if url is None:
url = f"{self.base_url}/test.html" url = f"{self.base_url}/test.html"
self.servoshell = subprocess.Popen(["target/release/servo", "--devtools=6080", url]) self.servoshell = subprocess.Popen([f"target/{self.build_type.directory_name()}/servo", "--devtools=6080", url])
# FIXME: Dont do this # FIXME: Dont do this
time.sleep(1) time.sleep(1)
@ -269,8 +271,9 @@ class DevtoolsTests(unittest.IsolatedAsyncioTestCase):
client.disconnect() client.disconnect()
def run_tests(script_path): def run_tests(script_path, build_type: BuildType):
DevtoolsTests.script_path = script_path DevtoolsTests.script_path = script_path
DevtoolsTests.build_type = build_type
verbosity = 1 if logging.getLogger().level >= logging.WARN else 2 verbosity = 1 if logging.getLogger().level >= logging.WARN else 2
suite = unittest.TestLoader().loadTestsFromTestCase(DevtoolsTests) suite = unittest.TestLoader().loadTestsFromTestCase(DevtoolsTests)
return unittest.TextTestRunner(verbosity=verbosity).run(suite).wasSuccessful() return unittest.TextTestRunner(verbosity=verbosity).run(suite).wasSuccessful()

View file

@ -344,9 +344,10 @@ class MachCommands(CommandBase):
return 0 if passed else 1 return 0 if passed else 1
@Command("test-devtools", description="Run tests for devtools.", category="testing") @Command("test-devtools", description="Run tests for devtools.", category="testing")
def test_devtools(self): @CommandBase.common_command_arguments(build_type=True)
def test_devtools(self, build_type: BuildType, **kwargs):
print("Running devtools tests...") print("Running devtools tests...")
passed = servo.devtools_tests.run_tests(SCRIPT_PATH) passed = servo.devtools_tests.run_tests(SCRIPT_PATH, build_type)
return 0 if passed else 1 return 0 if passed else 1
@Command( @Command(