Bug 1209312 - Accept test_objects in testing/xpcshell/mach_commands.py to support |./mach test|. r=jgraham

--HG--
extra : commitid : 7hOvYy0xdzm
This commit is contained in:
Chris Manchester 2015-09-29 12:59:55 -07:00
parent 53380b4f25
commit 6a45b54812

View File

@ -59,8 +59,6 @@ class XPCShellRunner(MozbuildObject):
def run_test(self, **kwargs):
"""Runs an individual xpcshell test."""
from mozbuild.testing import TestResolver
from manifestparser import TestManifest
# TODO Bug 794506 remove once mach integrates with virtualenv.
build_path = os.path.join(self.topobjdir, 'build')
@ -84,12 +82,15 @@ class XPCShellRunner(MozbuildObject):
self.log_manager.enable_unstructured()
tests_dir = os.path.join(self.topobjdir, '_tests', 'xpcshell')
modules_dir = os.path.join(self.topobjdir, '_tests', 'modules')
# We want output from the test to be written immediately if we are only
# running a single test.
single_test = (kwargs["testPaths"] is not None or
(manifest and len(manifest.test_paths())==1))
sequential = kwargs["sequential"] or single_test
single_test = (len(kwargs["testPaths"]) == 1 and
os.path.isfile(kwargs["testPaths"][0]) or
kwargs["manifest"] and
(len(kwargs["manifest"].test_paths()) == 1))
if single_test:
kwargs["verbose"] = True
if kwargs["xpcshell"] is None:
kwargs["xpcshell"] = self.get_binary_path('xpcshell')
@ -334,10 +335,15 @@ class MachCommands(MachCommandBase):
description='Run XPCOM Shell tests (API direct unit testing)',
conditions=[lambda *args: True],
parser=get_parser)
def run_xpcshell_test(self, **params):
def run_xpcshell_test(self, test_objects=None, **params):
from mozbuild.controller.building import BuildDriver
if test_objects is not None:
from manifestparser import TestManifest
m = TestManifest()
m.tests.extend(test_objects)
params['manifest'] = m
# We should probably have a utility function to ensure the tree is
# ready to run tests. Until then, we just create the state dir (in
# case the tree wasn't built with mach).