Auto merge of #5542 - mbrubeck:test-unit, r=metajack

Moved from #5512. r? @larsbergstrom or @metajack or @Manishearth
This commit is contained in:
bors-servo 2015-04-07 11:13:37 -05:00
commit bd7e4d661a

View file

@ -102,31 +102,37 @@ 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 = []
self.ensure_bootstrapped()
self.ensure_built_tests()
if component is not None:
if package is not None:
print("Please use either -p or -c, not both.")
return 1
package = component
ret = self.run_test("servo", test_name) != 0
self.ensure_bootstrapped()
def cargo_test(component):
return 0 != subprocess.call(
["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)
else:
for c in os.listdir("components"):
if c != "servo":
ret = ret or cargo_test(c)
if package is not None:
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',