mirror of
https://github.com/servo/servo.git
synced 2025-07-24 15:50:21 +01:00
This commit is contained in:
parent
0c8e74dcec
commit
9a698b7bfb
1 changed files with 0 additions and 82 deletions
|
@ -13,9 +13,6 @@ import re
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import os.path as path
|
import os.path as path
|
||||||
import copy
|
|
||||||
from collections import OrderedDict
|
|
||||||
import time
|
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
@ -24,7 +21,6 @@ import wpt.manifestupdate
|
||||||
import wpt.run
|
import wpt.run
|
||||||
import wpt.update
|
import wpt.update
|
||||||
|
|
||||||
from mach.registrar import Registrar
|
|
||||||
from mach.decorators import (
|
from mach.decorators import (
|
||||||
CommandArgument,
|
CommandArgument,
|
||||||
CommandProvider,
|
CommandProvider,
|
||||||
|
@ -41,18 +37,6 @@ PROJECT_TOPLEVEL_PATH = os.path.abspath(os.path.join(SCRIPT_PATH, "..", ".."))
|
||||||
WEB_PLATFORM_TESTS_PATH = os.path.join("tests", "wpt", "tests")
|
WEB_PLATFORM_TESTS_PATH = os.path.join("tests", "wpt", "tests")
|
||||||
SERVO_TESTS_PATH = os.path.join("tests", "wpt", "mozilla", "tests")
|
SERVO_TESTS_PATH = os.path.join("tests", "wpt", "mozilla", "tests")
|
||||||
|
|
||||||
TEST_SUITES = OrderedDict([
|
|
||||||
("wpt", {"kwargs": {"release": False},
|
|
||||||
"paths": [path.abspath(WEB_PLATFORM_TESTS_PATH),
|
|
||||||
path.abspath(SERVO_TESTS_PATH)],
|
|
||||||
"include_arg": "include"}),
|
|
||||||
("unit", {"kwargs": {},
|
|
||||||
"paths": [path.abspath(path.join("tests", "unit"))],
|
|
||||||
"include_arg": "test_name"}),
|
|
||||||
])
|
|
||||||
|
|
||||||
TEST_SUITES_BY_PREFIX = {path: k for k, v in TEST_SUITES.items() if "paths" in v for path in v["paths"]}
|
|
||||||
|
|
||||||
|
|
||||||
def format_toml_files_with_taplo(check_only: bool = True) -> int:
|
def format_toml_files_with_taplo(check_only: bool = True) -> int:
|
||||||
taplo = shutil.which("taplo")
|
taplo = shutil.which("taplo")
|
||||||
|
@ -76,72 +60,6 @@ class MachCommands(CommandBase):
|
||||||
if not hasattr(self.context, "built_tests"):
|
if not hasattr(self.context, "built_tests"):
|
||||||
self.context.built_tests = False
|
self.context.built_tests = False
|
||||||
|
|
||||||
@Command('test',
|
|
||||||
description='Run specified Servo tests',
|
|
||||||
category='testing')
|
|
||||||
@CommandArgument('params', default=None, nargs="...",
|
|
||||||
help="Optionally select test based on "
|
|
||||||
"test file directory")
|
|
||||||
@CommandArgument('--release', default=False, action="store_true",
|
|
||||||
help="Run with a release build of servo")
|
|
||||||
@CommandArgument('--all', default=False, action="store_true", dest="all_suites",
|
|
||||||
help="Run all test suites")
|
|
||||||
def test(self, params, release=False, all_suites=False):
|
|
||||||
suites = copy.deepcopy(TEST_SUITES)
|
|
||||||
suites["wpt"]["kwargs"] = {"release": release}
|
|
||||||
suites["unit"]["kwargs"] = {}
|
|
||||||
|
|
||||||
selected_suites = OrderedDict()
|
|
||||||
|
|
||||||
if params is None:
|
|
||||||
if all_suites:
|
|
||||||
params = suites.keys()
|
|
||||||
else:
|
|
||||||
print("Specify a test path or suite name, or pass --all to run all test suites.\n\nAvailable suites:")
|
|
||||||
for s in suites:
|
|
||||||
print(" %s" % s)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
for arg in params:
|
|
||||||
found = False
|
|
||||||
if arg in suites and arg not in selected_suites:
|
|
||||||
selected_suites[arg] = []
|
|
||||||
found = True
|
|
||||||
else:
|
|
||||||
suite = self.suite_for_path(arg)
|
|
||||||
if suite is not None:
|
|
||||||
if suite not in selected_suites:
|
|
||||||
selected_suites[suite] = []
|
|
||||||
selected_suites[suite].append(arg)
|
|
||||||
found = True
|
|
||||||
break
|
|
||||||
|
|
||||||
if not found:
|
|
||||||
print("%s is not a valid test path or suite name" % arg)
|
|
||||||
return 1
|
|
||||||
|
|
||||||
test_start = time.time()
|
|
||||||
for suite, tests in selected_suites.items():
|
|
||||||
props = suites[suite]
|
|
||||||
kwargs = props.get("kwargs", {})
|
|
||||||
if tests:
|
|
||||||
kwargs[props["include_arg"]] = tests
|
|
||||||
|
|
||||||
Registrar.dispatch("test-%s" % suite, context=self.context, **kwargs)
|
|
||||||
|
|
||||||
elapsed = time.time() - test_start
|
|
||||||
|
|
||||||
print("Tests completed in %0.2fs" % elapsed)
|
|
||||||
|
|
||||||
# Helper to determine which test suite owns the path
|
|
||||||
def suite_for_path(self, path_arg):
|
|
||||||
if os.path.exists(path.abspath(path_arg)):
|
|
||||||
abs_path = path.abspath(path_arg)
|
|
||||||
for prefix, suite in TEST_SUITES_BY_PREFIX.items():
|
|
||||||
if abs_path.startswith(prefix):
|
|
||||||
return suite
|
|
||||||
return None
|
|
||||||
|
|
||||||
@Command('test-perf',
|
@Command('test-perf',
|
||||||
description='Run the page load performance test',
|
description='Run the page load performance test',
|
||||||
category='testing')
|
category='testing')
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue