diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 59a30207c89..13dd21e9405 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -13,9 +13,6 @@ import re import sys import os import os.path as path -import copy -from collections import OrderedDict -import time import shutil import subprocess @@ -24,7 +21,6 @@ import wpt.manifestupdate import wpt.run import wpt.update -from mach.registrar import Registrar from mach.decorators import ( CommandArgument, 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") 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: taplo = shutil.which("taplo") @@ -76,72 +60,6 @@ class MachCommands(CommandBase): if not hasattr(self.context, "built_tests"): 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', description='Run the page load performance test', category='testing')