From 910869f63cd2e884f6f353c3cf4d9e0965aac259 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Fri, 3 Apr 2015 11:46:40 -0700 Subject: [PATCH 1/2] Change `mach test-unit` parameter from `-c` to `-p` For consistency with Cargo params, and related mach commands like `mach update-cargo`. The `-c` version is still available as an alias for compatibility with old scripts. --- python/servo/testing_commands.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 98ab52fdf4f..299064d5a37 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -102,14 +102,22 @@ class MachCommands(CommandBase): @Command('test-unit', description='Run unit tests', category='testing') + @CommandArgument('--package', '-p', default=None, + help="Specific package to test") @CommandArgument('--component', '-c', default=None, - help="Specific component to test") + help="Alias for --package") @CommandArgument('test_name', nargs=argparse.REMAINDER, help="Only run tests that match this pattern") - def test_unit(self, test_name=None, component=None): + def test_unit(self, test_name=None, component=None, package=None): if test_name is None: test_name = [] + if component is not None: + if package is not None: + print("Please use either -p or -c, not both.") + return 1 + package = component + self.ensure_bootstrapped() self.ensure_built_tests() @@ -120,8 +128,8 @@ class MachCommands(CommandBase): ["cargo", "test", "-p", component] + test_name, env=self.build_env(), cwd=self.servo_crate()) - if component is not None: - ret = ret or cargo_test(component) + if package is not None: + ret = ret or cargo_test(package) else: for c in os.listdir("components"): if c != "servo": From 32e5679175d845eeb244b9a05b9e275b30d347ba Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Fri, 3 Apr 2015 12:02:33 -0700 Subject: [PATCH 2/2] `mach test-unit -p` should not build all tests This changes the `mach test-unit -p foo` command to build only the requested crate, not the entire `servo` crate. --- python/servo/testing_commands.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 299064d5a37..b64d0030d18 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -119,9 +119,6 @@ class MachCommands(CommandBase): package = component self.ensure_bootstrapped() - self.ensure_built_tests() - - ret = self.run_test("servo", test_name) != 0 def cargo_test(component): return 0 != subprocess.call( @@ -129,12 +126,13 @@ class MachCommands(CommandBase): + test_name, env=self.build_env(), cwd=self.servo_crate()) if package is not None: - ret = ret or cargo_test(package) - else: - for c in os.listdir("components"): - if c != "servo": - ret = ret or cargo_test(c) + return cargo_test(package) + self.ensure_built_tests() + ret = self.run_test("servo", test_name) != 0 + for c in os.listdir("components"): + if c != "servo": + ret = ret or cargo_test(c) return ret @Command('test-ref',