Bug 1345109 - Ensure |mach python-test| errors out if no tests are found, r?mshal draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Tue, 07 Mar 2017 10:55:07 -0500
changeset 494771 695cacaf1c352c3dc114053640e5fdd68f787f14
parent 494682 575e82f15c295cd56746fe26847ba95eae197954
child 494772 117beb327de099df9e5c69ca33e1056c2cea0f25
child 494791 75fbc39b13a81b009d6b40be6f45034878a737d9
push id48128
push userahalberstadt@mozilla.com
push dateTue, 07 Mar 2017 19:39:39 +0000
reviewersmshal
bugs1345109
milestone55.0a1
Bug 1345109 - Ensure |mach python-test| errors out if no tests are found, r?mshal Because test_objects was a generator, using it in the condition always returned True, even if no tests were found. But extending test_objects to the manifest, converts it to a list. So this patch simply moves the 'no tests' check a bit later on. MozReview-Commit-ID: JpETWD1WQWH
python/mach_commands.py
--- a/python/mach_commands.py
+++ b/python/mach_commands.py
@@ -108,25 +108,25 @@ class MachCommands(MachCommandBase):
             if tests:
                 # If we were given test paths, try to find tests matching them.
                 test_objects = resolver.resolve_tests(paths=tests,
                                                       flavor='python')
             else:
                 # Otherwise just run everything in PYTHON_UNITTEST_MANIFESTS
                 test_objects = resolver.resolve_tests(flavor='python')
 
-        if not test_objects:
+        mp = TestManifest()
+        mp.tests.extend(test_objects)
+
+        if not mp.tests:
             message = 'TEST-UNEXPECTED-FAIL | No tests collected ' + \
                       '(Not in PYTHON_UNITTEST_MANIFESTS?)'
             self.log(logging.WARN, 'python-test', {}, message)
             return 1
 
-        mp = TestManifest()
-        mp.tests.extend(test_objects)
-
         filters = []
         if subsuite == 'default':
             filters.append(mpf.subsuite(None))
         elif subsuite:
             filters.append(mpf.subsuite(subsuite))
 
         tests = mp.active_tests(filters=filters, disabled=False, **mozinfo.info)