Bug 1136700 - enable tweaking of the maximum number of timeouts for mochitests; r=jmaher
authorNathan Froyd <froydnj@mozilla.com>
Wed, 25 Feb 2015 09:23:54 -0500
changeset 249120 ab9f361648bd428a55366703b1bf5ee5049c7ec9
parent 249119 513d6a986d1419b8b2ced307cec668a19d080e28
child 249121 2e44b99511507487e07bea8ff1ae9438714079df
push id7860
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:46:02 +0000
treeherdermozilla-aurora@8ac636cd51f3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1136700
milestone39.0a1
Bug 1136700 - enable tweaking of the maximum number of timeouts for mochitests; r=jmaher When running tests locally, it's occasionally useful to be able to increase the number of tests permitted to timeout before declaring the test run a failure. This patch adds the necessary bits to SimpleTest and the appropriate amount of plumbing to runtests.py and mach to make that so.
testing/mochitest/mach_commands.py
testing/mochitest/mochitest_options.py
testing/mochitest/runtests.py
testing/mochitest/tests/SimpleTest/setup.js
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -251,16 +251,17 @@ class MochitestRunner(MozbuildObject):
             install_extension=None,
             quiet=False,
             environment=[],
             app_override=None,
             bisectChunk=None,
             runByDir=False,
             useTestMediaDevices=False,
             timeout=None,
+            max_timeouts=None,
             **kwargs):
         """Runs a mochitest.
 
         test_paths are path to tests. They can be a relative path from the
         top source directory, an absolute filename, or a directory containing
         test files.
 
         suite is the type of mochitest to run. It can be one of ('plain',
@@ -388,16 +389,18 @@ class MochitestRunner(MozbuildObject):
         options.quiet = quiet
         options.environment = environment
         options.extraPrefs = extraPrefs
         options.bisectChunk = bisectChunk
         options.runByDir = runByDir
         options.useTestMediaDevices = useTestMediaDevices
         if timeout:
             options.timeout = int(timeout)
+        if max_timeouts:
+            options.maxTimeouts = int(max_timeouts)
 
         options.failureFile = failure_file_path
         if install_extension is not None:
             options.extensionsToInstall = [
                 os.path.join(
                     self.topsrcdir,
                     install_extension)]
 
@@ -724,16 +727,20 @@ def MochitestCommand(func):
     func = app_override(func)
 
     timeout = CommandArgument(
         '--timeout',
         default=None,
         help='The per-test timeout time in seconds (default: 60 seconds)')
     func = timeout(func)
 
+    max_timeouts = CommandArgument('--max-timeouts', default=None,
+        help='The maximum number of timeouts permitted before halting testing')
+    func = max_timeouts(func)
+
     return func
 
 
 def B2GCommand(func):
     """Decorator that adds shared command arguments to b2g mochitest commands."""
 
     busybox = CommandArgument(
         '--busybox',
--- a/testing/mochitest/mochitest_options.py
+++ b/testing/mochitest/mochitest_options.py
@@ -473,16 +473,22 @@ class MochitestOptions(optparse.OptionPa
           "dest": "debuggerArgs",
           "help": "pass the given args to the debugger _before_ the application on the command line",
           }],
         [["--debugger-interactive"],
          {"action": "store_true",
           "dest": "debuggerInteractive",
           "help": "prevents the test harness from redirecting stdout and stderr for interactive debuggers",
           }],
+        [["--max-timeouts"],
+         { "type": "int",
+           "dest": "maxTimeouts",
+           "help": "maximum number of timeouts permitted before halting testing",
+           "default": None,
+           }],
     ]
 
     def __init__(self, **kwargs):
 
         optparse.OptionParser.__init__(self, **kwargs)
         for option, value in self.mochitest_options:
             # Allocate new lists so references to original don't get mutated.
             # allowing multiple uses within a single process.
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -587,16 +587,18 @@ class MochitestUtilsMixin(object):
            options.a11y or options.webapprtChrome or options.jetpackPackage or \
            options.jetpackAddon:
             self.makeTestConfig(options)
         else:
             if options.autorun:
                 self.urlOpts.append("autorun=1")
             if options.timeout:
                 self.urlOpts.append("timeout=%d" % options.timeout)
+            if options.maxTimeouts:
+                self.urlOpts.append("maxTimeouts=%d" % options.maxTimeouts)
             if options.closeWhenDone:
                 self.urlOpts.append("closeWhenDone=1")
             if options.webapprtContent:
                 self.urlOpts.append("testRoot=webapprtContent")
             if options.logFile:
                 self.urlOpts.append(
                     "logFile=" +
                     encodeURIComponent(
--- a/testing/mochitest/tests/SimpleTest/setup.js
+++ b/testing/mochitest/tests/SimpleTest/setup.js
@@ -141,16 +141,20 @@ if (params.dumpAboutMemoryAfterTest) {
 if (params.dumpDMDAfterTest) {
   TestRunner.dumpDMDAfterTest = true;
 }
 
 if (params.interactiveDebugger) {
   TestRunner.structuredLogger.interactiveDebugger = true;
 }
 
+if (params.maxTimeouts) {
+  TestRunner.maxTimeouts = params.maxTimeouts;
+}
+
 // Log things to the console if appropriate.
 TestRunner.logger.addListener("dumpListener", consoleLevel + "", function(msg) {
   dump(msg.info.join(' ') + "\n");
 });
 
 var gTestList = [];
 var RunSet = {};
 RunSet.runall = function(e) {