aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo/testing_commands.py
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2014-12-06 04:49:00 -0700
committerbors-servo <metajack+bors@gmail.com>2014-12-06 04:49:00 -0700
commit2d0e96e1331668fea7313efd688fe7dba6d7ebed (patch)
tree0c164694e9f40dd9c75ff817bfc1c91bb5fdb8ca /python/servo/testing_commands.py
parent3eec780c0050d034c06c3b7b2128401a8b3b1a37 (diff)
parent19d119785c328e6f06fae99bbf6ed1f20eebf14a (diff)
downloadservo-2d0e96e1331668fea7313efd688fe7dba6d7ebed.tar.gz
servo-2d0e96e1331668fea7313efd688fe7dba6d7ebed.zip
auto merge of #4229 : mttr/servo/mach_unit_test_select_component, r=Manishearth
Example usage: `./mach test-unit -c style`
Diffstat (limited to 'python/servo/testing_commands.py')
-rw-r--r--python/servo/testing_commands.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py
index 9581142e941..0bedbdfe30e 100644
--- a/python/servo/testing_commands.py
+++ b/python/servo/testing_commands.py
@@ -36,7 +36,9 @@ class MachCommands(CommandBase):
for filename in target_contents:
if filename.startswith(prefix + "-"):
filepath = path.join(
- self.context.topdir, "components", "servo", "target", filename)
+ self.context.topdir, "components", "servo",
+ "target", filename)
+
if path.isfile(filepath) and os.access(filepath, os.X_OK):
return filepath
@@ -94,11 +96,11 @@ class MachCommands(CommandBase):
@Command('test-unit',
description='Run unit tests',
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")
- def test_unit(self, test_name=None):
- if test_name is None:
- test_name = []
+ def test_unit(self, test_name, component=None):
self.ensure_bootstrapped()
self.ensure_built_tests()
@@ -106,12 +108,15 @@ class MachCommands(CommandBase):
def cargo_test(component):
return 0 != subprocess.call(
- ["cargo", "test", "-p", component] + test_name,
- env=self.build_env(), cwd=self.servo_crate())
+ ["cargo", "test", "-p", component]
+ + test_name, env=self.build_env(), cwd=self.servo_crate())
- for component in os.listdir("components"):
- if component != "servo":
- ret = ret or cargo_test(component)
+ if component is not None:
+ ret = ret or cargo_test(component)
+ else:
+ for c in os.listdir("components"):
+ if c != "servo":
+ ret = ret or cargo_test(c)
return ret