Bug 1332573 - Always set status in mochitest even if no tests were found, r?pyang draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 20 Jan 2017 09:37:52 -0500
changeset 464161 8ac83907cad371243041794e6763ae132ac6618b
parent 464156 e674ae0954df1bf18645ef7dba91365b8282f27e
child 542873 e9a381a56b4a44ea43ffc6750f69dd0fe5f9c822
push id42293
push userahalberstadt@mozilla.com
push dateFri, 20 Jan 2017 14:40:17 +0000
reviewerspyang
bugs1332573
milestone53.0a1
Bug 1332573 - Always set status in mochitest even if no tests were found, r?pyang This fixes a regression in bug 1332573 where if no tests are found by the getActiveTests function, the status variable never gets set. This ensures that we always set status, and that it will be set to a non-zero return code if any of the calls to runApp fail. MozReview-Commit-ID: 20M7FcBs0DF
testing/mochitest/runtests.py
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -317,16 +317,17 @@ def call(*args, **kwargs):
 
 def killPid(pid, log):
     # see also https://bugzilla.mozilla.org/show_bug.cgi?id=911249#c58
     try:
         os.kill(pid, getattr(signal, "SIGKILL", signal.SIGTERM))
     except Exception as e:
         log.info("Failed to kill process %d: %s" % (pid, str(e)))
 
+
 if mozinfo.isWin:
     import ctypes.wintypes
 
     def isPidAlive(pid):
         STILL_ACTIVE = 259
         PROCESS_QUERY_LIMITED_INFORMATION = 0x1000
         pHandle = ctypes.windll.kernel32.OpenProcess(
             PROCESS_QUERY_LIMITED_INFORMATION,
@@ -2353,16 +2354,17 @@ toolbar#nav-bar {
 
         if self.browserEnv is None:
             return 1
 
         if self.mozLogs:
             self.browserEnv["MOZ_LOG_FILE"] = "{}/moz-pid=%PID-uid={}.log".format(
                 self.browserEnv["MOZ_UPLOAD_DIR"], str(uuid.uuid4()))
 
+        status = 0
         try:
             self.startServers(options, debuggerInfo)
 
             if options.immersiveMode:
                 options.browserArgs.extend(('-firefoxpath', options.app))
                 options.app = self.immersiveHelperPath
 
             if options.jsdebugger:
@@ -2412,33 +2414,35 @@ toolbar#nav-bar {
                 testURL = self.buildTestURL(options, scheme=scheme)
 
                 self.buildURLOptions(options, self.browserEnv)
                 if self.urlOpts:
                     testURL += "?" + "&".join(self.urlOpts)
 
                 self.log.info("runtests.py | Running with e10s: {}".format(options.e10s))
                 self.log.info("runtests.py | Running tests: start.\n")
-                status = self.runApp(testURL,
-                                     self.browserEnv,
-                                     options.app,
-                                     profile=self.profile,
-                                     extraArgs=options.browserArgs,
-                                     utilityPath=options.utilityPath,
-                                     debuggerInfo=debuggerInfo,
-                                     valgrindPath=valgrindPath,
-                                     valgrindArgs=valgrindArgs,
-                                     valgrindSuppFiles=valgrindSuppFiles,
-                                     symbolsPath=options.symbolsPath,
-                                     timeout=timeout,
-                                     detectShutdownLeaks=detectShutdownLeaks,
-                                     screenshotOnFail=options.screenshotOnFail,
-                                     bisectChunk=options.bisectChunk,
-                                     marionette_args=marionette_args,
-                                     )
+                ret = self.runApp(
+                    testURL,
+                    self.browserEnv,
+                    options.app,
+                    profile=self.profile,
+                    extraArgs=options.browserArgs,
+                    utilityPath=options.utilityPath,
+                    debuggerInfo=debuggerInfo,
+                    valgrindPath=valgrindPath,
+                    valgrindArgs=valgrindArgs,
+                    valgrindSuppFiles=valgrindSuppFiles,
+                    symbolsPath=options.symbolsPath,
+                    timeout=timeout,
+                    detectShutdownLeaks=detectShutdownLeaks,
+                    screenshotOnFail=options.screenshotOnFail,
+                    bisectChunk=options.bisectChunk,
+                    marionette_args=marionette_args,
+                )
+                status = ret or status
         except KeyboardInterrupt:
             self.log.info("runtests.py | Received keyboard interrupt.\n")
             status = -1
         except:
             traceback.print_exc()
             self.log.error(
                 "Automation Error: Received unexpected exception while running application\n")
             status = 1
@@ -2730,10 +2734,11 @@ def cli(args=sys.argv[1:]):
     parser = MochitestArgumentParser(app='generic')
     options = parser.parse_args(args)
     if options is None:
         # parsing error
         sys.exit(1)
 
     return run_test_harness(parser, options)
 
+
 if __name__ == "__main__":
     sys.exit(cli())