Bug 1052211 - fix default closure behaviour for mochitests and add --auto-close option to force closing the browser, r=ted
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 11 Sep 2014 15:29:57 +0100
changeset 207470 437731e3c70484efcb099a03c5beed7e0c1c788e
parent 207469 240297b949aab7057f9619df2a6991dc4b82bd4b
child 207471 df3fe2e4bf8fe4a97a804e91b6128d035939844d
push id27555
push userryanvm@gmail.com
push dateFri, 26 Sep 2014 20:30:28 +0000
treeherderautoland@4ff52be673f6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs1052211
milestone35.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 1052211 - fix default closure behaviour for mochitests and add --auto-close option to force closing the browser, r=ted
testing/mochitest/mach_commands.py
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -182,17 +182,17 @@ class MochitestRunner(MozbuildObject):
 
         options.b2gPath = b2g_home
         options.logdir = self.mochitest_dir
         options.httpdPath = self.mochitest_dir
         options.xrePath = xre_path
         return mochitest.run_remote_mochitests(parser, options)
 
     def run_desktop_test(self, context, suite=None, test_paths=None, debugger=None,
-        debugger_args=None, slowscript=False, screenshot_on_fail = False, shuffle=False, keep_open=False,
+        debugger_args=None, slowscript=False, screenshot_on_fail = False, shuffle=False, closure_behaviour='auto',
         rerun_failures=False, no_autorun=False, repeat=0, run_until_failure=False,
         slow=False, chunk_by_dir=0, total_chunks=None, this_chunk=None, extraPrefs=[],
         jsdebugger=False, debug_on_failure=False, start_at=None, end_at=None,
         e10s=False, content_sandbox='off', dmd=False, dump_output_directory=None,
         dump_about_memory_after_test=False, dump_dmd_after_test=False,
         install_extension=None, quiet=False, environment=[], app_override=None, bisectChunk=None, runByDir=False,
         useTestMediaDevices=False, **kwargs):
         """Runs a mochitest.
@@ -209,17 +209,17 @@ class MochitestRunner(MozbuildObject):
 
         debugger_args are the arguments passed to the debugger.
 
         slowscript is true if the user has requested the SIGSEGV mechanism of
         invoking the slow script dialog.
 
         shuffle is whether test order should be shuffled (defaults to false).
 
-        keep_open denotes whether to keep the browser open after tests
+        closure_behaviour denotes whether to keep the browser open after tests
         complete.
         """
         if rerun_failures and test_paths:
             print('Cannot specify both --rerun-failures and a test path.')
             return 1
 
         # Make absolute paths relative before calling os.chdir() below.
         if test_paths:
@@ -289,17 +289,17 @@ class MochitestRunner(MozbuildObject):
             options.browserArgs.append("-test-mode")
         else:
             raise Exception('None or unrecognized mochitest suite type.')
 
         if dmd:
             options.dmdPath = self.bin_dir
 
         options.autorun = not no_autorun
-        options.closeWhenDone = not keep_open
+        options.closeWhenDone = closure_behaviour != 'open'
         options.slowscript = slowscript
         options.screenshotOnFail = screenshot_on_fail
         options.shuffle = shuffle
         options.consoleLevel = 'INFO'
         options.repeat = repeat
         options.runUntilFailure = run_until_failure
         options.runSlower = slow
         options.testingModulesDir = os.path.join(self.tests_dir, 'modules')
@@ -342,17 +342,17 @@ class MochitestRunner(MozbuildObject):
                 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()
             manifest.tests.extend(tests)
 
-            if len(tests) == 1:
+            if len(tests) == 1 and closure_behaviour == 'auto' and suite == 'plain':
                 options.closeWhenDone = False
 
             options.manifestFile = manifest
 
         if rerun_failures:
             options.testManifest = failure_file_path
 
         if debugger:
@@ -429,20 +429,26 @@ def MochitestCommand(func):
     screenshot_on_fail = CommandArgument('--screenshot-on-fail', action='store_true',
         help='Take screenshots on all test failures. Set $MOZ_UPLOAD_DIR to a directory for storing the screenshots.')
     func = screenshot_on_fail(func)
 
     shuffle = CommandArgument('--shuffle', action='store_true',
         help='Shuffle execution order.')
     func = shuffle(func)
 
-    keep_open = CommandArgument('--keep-open', action='store_true',
-        help='Keep the browser open after tests complete.')
+    keep_open = CommandArgument('--keep-open', action='store_const',
+        dest='closure_behaviour', const='open', default='auto',
+        help='Always keep the browser open after tests complete.')
     func = keep_open(func)
 
+    autoclose = CommandArgument('--auto-close', action='store_const',
+        dest='closure_behaviour', const='close', default='auto',
+        help='Always close the browser after tests complete.')
+    func = autoclose(func)
+
     rerun = CommandArgument('--rerun-failures', action='store_true',
         help='Run only the tests that failed during the last test run.')
     func = rerun(func)
 
     autorun = CommandArgument('--no-autorun', action='store_true',
         help='Do not starting running tests automatically.')
     func = autorun(func)