Bug 982560 - Fix mach fails to find tests in subdirectory. r=gps
authorTing-Yu Lin <tlin@mozilla.com>
Tue, 01 Jul 2014 23:21:00 +0200
changeset 193037 545d28bfe4fbfeb87576cfb2e4e1322ccaba8ac5
parent 193036 f82a8a7c0cb981394872e444f212a89ee6aab60e
child 193038 1ff371321520ed2886c83a246878af17b4f4a6d0
push id27103
push usercbook@mozilla.com
push dateWed, 09 Jul 2014 13:55:18 +0000
treeherdermozilla-central@f945d50e50fc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 982560 - Fix mach fails to find tests in subdirectory. r=gps Make the test paths relative to topsrcdir before passing them to TestResolver. Also do not passing cwd to TestResolver since it will filter out tests that do not live under the directory where the mach command is executed. Verification steps: Execute a mach test command from any subdirectory. For example: $ cd testing/tps/ $ ../../mach xpcshell-test ../../services/fxaccounts/tests/xpcshell/ $ ../../mach test ../../services/fxaccounts/tests/xpcshell/
--- a/testing/mach_commands.py
+++ b/testing/mach_commands.py
@@ -185,18 +185,18 @@ class Test(MachCommandBase):
             for suite, v in TEST_SUITES.items():
                 if entry in v.get('aliases', []):
                     suitefound = True
             if suitefound:
             # Now look for file/directory matches in the TestResolver.
-            tests = list(resolver.resolve_tests(paths=[entry],
-                cwd=self._mach_context.cwd))
+            relpath = self._wrap_path_argument(entry).relpath()
+            tests = list(resolver.resolve_tests(paths=[relpath]))
             if not tests:
                 print('UNKNOWN TEST: %s' % entry, file=sys.stderr)
         if not run_suites and not run_tests:
             return 1
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -333,18 +333,17 @@ class MochitestRunner(MozbuildObject):
             options.extensionsToInstall = [os.path.join(self.topsrcdir,install_extension)]
         for k, v in kwargs.iteritems():
             setattr(options, k, v)
         if test_paths:
             resolver = self._spawn(TestResolver)
-            tests = list(resolver.resolve_tests(paths=test_paths, flavor=flavor,
-                cwd=context.cwd))
+            tests = list(resolver.resolve_tests(paths=test_paths, flavor=flavor))
             if not tests:
                 print('No tests could be found in the path specified. Please '
                     'specify a path that is a test file or is a directory '
                     'containing tests.')
                 return 1
             manifest = TestManifest()
--- a/testing/xpcshell/mach_commands.py
+++ b/testing/xpcshell/mach_commands.py
@@ -82,23 +82,25 @@ class XPCShellRunner(MozbuildObject):
         if test_paths == ['all']:
                            keep_going=keep_going, shuffle=shuffle, sequential=sequential,
                            debugger=debugger, debuggerArgs=debuggerArgs,
+        elif test_paths:
+            test_paths = [self._wrap_path_argument(p).relpath() for p in test_paths]
         if test_objects:
             tests = test_objects
             resolver = self._spawn(TestResolver)
             tests = list(resolver.resolve_tests(paths=test_paths,
-                flavor='xpcshell', cwd=self.cwd))
+                flavor='xpcshell'))
         if not tests:
             raise InvalidTestPathError('We could not find an xpcshell test '
                 'for the passed test path. Please select a path that is '
                 'a test file or is a directory containing xpcshell tests.')
         # Dynamically write out a manifest holding all the discovered tests.
         manifest = TestManifest()