Bug 969437 - part 1 - introduce a --quiet option for mochitests; r=jmaher
authorNathan Froyd <froydnj@mozilla.com>
Fri, 07 Mar 2014 11:42:07 -0500
changeset 175622 c7cecd865ea6190d9bf84ce31a78f4586fc62184
parent 175621 2dcb65629793c967116879352bef52fd82a375d0
child 175623 c8608d5e26ff07d35aaa81c755a3fde1fc840c0e
push id26496
push userkwierso@gmail.com
push dateFri, 28 Mar 2014 02:28:34 +0000
treeherdermozilla-central@3c09159e01da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs969437
milestone31.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 969437 - part 1 - introduce a --quiet option for mochitests; r=jmaher
testing/mochitest/mach_commands.py
testing/mochitest/mochitest_options.py
testing/mochitest/runtests.py
testing/mochitest/tests/SimpleTest/SimpleTest.js
testing/mochitest/tests/SimpleTest/TestRunner.js
testing/mochitest/tests/SimpleTest/setup.js
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -185,17 +185,17 @@ class MochitestRunner(MozbuildObject):
 
     def run_desktop_test(self, context, suite=None, test_paths=None, debugger=None,
         debugger_args=None, slowscript=False, shuffle=False, keep_open=False,
         rerun_failures=False, no_autorun=False, repeat=0, run_until_failure=False,
         slow=False, chunk_by_dir=0, total_chunks=None, this_chunk=None,
         jsdebugger=False, debug_on_failure=False, start_at=None, end_at=None,
         e10s=False, dmd=False, dump_output_directory=None,
         dump_about_memory_after_test=False, dump_dmd_after_test=False,
-        install_extension=None, **kwargs):
+        install_extension=None, quiet=False, **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',
         'chrome', 'browser', 'metro', 'a11y').
@@ -303,16 +303,17 @@ class MochitestRunner(MozbuildObject):
         options.jsdebugger = jsdebugger
         options.debugOnFailure = debug_on_failure
         options.startAt = start_at
         options.endAt = end_at
         options.e10s = e10s
         options.dumpAboutMemoryAfterTest = dump_about_memory_after_test
         options.dumpDMDAfterTest = dump_dmd_after_test
         options.dumpOutputDirectory = dump_output_directory
+        options.quiet = quiet
 
         options.failureFile = failure_file_path
         if install_extension != None:
             options.extensionsToInstall = [os.path.join(self.topsrcdir,install_extension)]
 
         for k, v in kwargs.iteritems():
             setattr(options, k, v)
 
@@ -496,16 +497,20 @@ def MochitestCommand(func):
             'executed.')
     func = path(func)
 
     install_extension = CommandArgument('--install-extension',
         help='Install given extension before running selected tests. ' \
             'Parameter is a path to xpi file.')
     func = install_extension(func)
 
+    quiet = CommandArgument('--quiet', default=False, action='store_true',
+        help='Do not print test log lines unless a failure occurs.')
+    func = quiet(func)
+
     return func
 
 def B2GCommand(func):
     """Decorator that adds shared command arguments to b2g mochitest commands."""
 
     busybox = CommandArgument('--busybox', default=None,
         help='Path to busybox binary to install on device')
     func = busybox(func)
--- a/testing/mochitest/mochitest_options.py
+++ b/testing/mochitest/mochitest_options.py
@@ -386,16 +386,22 @@ class MochitestOptions(optparse.OptionPa
         [["--slowscript"],
          { "action": "store_true",
            "default": False,
            "dest": "slowscript",
            "help": "Do not set the JS_DISABLE_SLOW_SCRIPT_SIGNALS env variable; "
                    "when not set, recoverable but misleading SIGSEGV instances "
                    "may occur in Ion/Odin JIT code."
         }],
+        [["--quiet"],
+         { "action": "store_true",
+           "default": False,
+           "dest": "quiet",
+           "help": "Do not print test log lines unless a failure occurs."
+         }],
     ]
 
     def __init__(self, **kwargs):
 
         optparse.OptionParser.__init__(self, **kwargs)
         for option, value in self.mochitest_options:
             self.add_option(*option, **value)
         addCommonOptions(self)
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -356,16 +356,18 @@ class MochitestUtilsMixin(object):
       if options.debugOnFailure:
         self.urlOpts.append("debugOnFailure=true")
       if options.dumpOutputDirectory:
         self.urlOpts.append("dumpOutputDirectory=%s" % encodeURIComponent(options.dumpOutputDirectory))
       if options.dumpAboutMemoryAfterTest:
         self.urlOpts.append("dumpAboutMemoryAfterTest=true")
       if options.dumpDMDAfterTest:
         self.urlOpts.append("dumpDMDAfterTest=true")
+      if options.quiet:
+        self.urlOpts.append("quiet=true")
 
   def getTestFlavor(self, options):
     if options.browserChrome:
       return "browser-chrome"
     elif options.chrome:
       return "chrome"
     elif options.a11y:
       return "a11y"
--- a/testing/mochitest/tests/SimpleTest/SimpleTest.js
+++ b/testing/mochitest/tests/SimpleTest/SimpleTest.js
@@ -308,17 +308,17 @@ SimpleTest.getTestFileURL = function(pat
 };
 
 SimpleTest._getCurrentTestURL = function() {
     return parentRunner && parentRunner.currentTestURL ||
            typeof gTestPath == "string" && gTestPath ||
            "unknown test url";
 };
 
-SimpleTest._forceLogMessageOutput = false;
+SimpleTest._forceLogMessageOutput = parentRunner && !parentRunner.quiet;
 
 /**
  * Force all test messages to be displayed.  Only applies for the current test.
  */
 SimpleTest.requestCompleteLog = function() {
     if (SimpleTest._forceLogMessageOutput)
         return;
 
--- a/testing/mochitest/tests/SimpleTest/TestRunner.js
+++ b/testing/mochitest/tests/SimpleTest/TestRunner.js
@@ -86,16 +86,17 @@ TestRunner._expectedMinAsserts = 0;
 TestRunner._expectedMaxAsserts = 0;
 
 TestRunner.timeout = 5 * 60 * 1000; // 5 minutes.
 TestRunner.maxTimeouts = 4; // halt testing after too many timeouts
 TestRunner.runSlower = false;
 TestRunner.dumpOutputDirectory = "";
 TestRunner.dumpAboutMemoryAfterTest = false;
 TestRunner.dumpDMDAfterTest = false;
+TestRunner.quiet = false;
 TestRunner.slowestTestTime = 0;
 TestRunner.slowestTestURL = "";
 
 TestRunner._expectingProcessCrash = false;
 
 /**
  * Make sure the tests don't hang indefinitely.
 **/
--- a/testing/mochitest/tests/SimpleTest/setup.js
+++ b/testing/mochitest/tests/SimpleTest/setup.js
@@ -130,16 +130,20 @@ if (params.dumpOutputDirectory) {
 if (params.dumpAboutMemoryAfterTest) {
   TestRunner.dumpAboutMemoryAfterTest = true;
 }
 
 if (params.dumpDMDAfterTest) {
   TestRunner.dumpDMDAfterTest = true;
 }
 
+if (params.quiet) {
+  TestRunner.quiet = true;
+}
+
 // Log things to the console if appropriate.
 TestRunner.logger.addListener("dumpListener", consoleLevel + "", function(msg) {
   dump(msg.num + " " + msg.level + " " + msg.info.join(' ') + "\n");
 });
 
 var gTestList = [];
 var RunSet = {}
 RunSet.runall = function(e) {