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 213833 545d28bfe4fbfeb87576cfb2e4e1322ccaba8ac5
parent 213832 f82a8a7c0cb981394872e444f212a89ee6aab60e
child 213834 1ff371321520ed2886c83a246878af17b4f4a6d0
push id3857
push userraliiev@mozilla.com
push dateTue, 02 Sep 2014 16:39:23 +0000
treeherdermozilla-beta@5638b907b505 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs982560
milestone33.0a1
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/
testing/mach_commands.py
testing/mochitest/mach_commands.py
testing/xpcshell/mach_commands.py
--- 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', []):
                     run_suites.add(suite)
                     suitefound = True
             if suitefound:
                 continue
 
             # 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]))
             run_tests.extend(tests)
 
             if not tests:
                 print('UNKNOWN TEST: %s' % entry, file=sys.stderr)
 
         if not run_suites and not run_tests:
             print(UNKNOWN_TEST)
             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']:
             self.run_suite(interactive=interactive,
                            keep_going=keep_going, shuffle=shuffle, sequential=sequential,
                            debugger=debugger, debuggerArgs=debuggerArgs,
                            debuggerInteractive=debuggerInteractive,
                            rerun_failures=rerun_failures)
             return
+        elif test_paths:
+            test_paths = [self._wrap_path_argument(p).relpath() for p in test_paths]
 
         if test_objects:
             tests = test_objects
         else:
             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()