Adds a --component (or -c) argument to test-unit

Example usage:

`./mach test-unit -c style`
This commit is contained in:
Matthew Rasmus 2014-12-04 16:13:23 -08:00
parent 3d5fa7b6e2
commit 0aa6d9c28e

View file

@ -96,11 +96,11 @@ class MachCommands(CommandBase):
@Command('test-unit', @Command('test-unit',
description='Run unit tests', description='Run unit tests',
category='testing') category='testing')
@CommandArgument('test_name', default=None, nargs="...", @CommandArgument('--component', '-c', default=None,
help="Specific component to test")
@CommandArgument('test_name', nargs=argparse.REMAINDER,
help="Only run tests that match this pattern") help="Only run tests that match this pattern")
def test_unit(self, test_name=None): def test_unit(self, test_name=None, component=None):
if test_name is None:
test_name = []
self.ensure_bootstrapped() self.ensure_bootstrapped()
self.ensure_built_tests() self.ensure_built_tests()
@ -108,12 +108,15 @@ class MachCommands(CommandBase):
def cargo_test(component): def cargo_test(component):
return 0 != subprocess.call( return 0 != subprocess.call(
["gdb", "--args", "cargo", "test", "-p", component] ["cargo", "test", "-p", component]
+ test_name, env=self.build_env(), cwd=self.servo_crate()) + test_name, env=self.build_env(), cwd=self.servo_crate())
for component in os.listdir("components"): if component is not None:
if component != "servo": ret = ret or cargo_test(component)
ret = ret or cargo_test(component) else:
for c in os.listdir("components"):
if c != "servo":
ret = ret or cargo_test(c)
return ret return ret