Bug 1020516 - Pass options.quiet into mochitest MessageLogger via constructor, r?ted draft
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Wed, 02 Nov 2016 13:42:57 -0400
changeset 432784 aacf2037b0bfe3a6de4392f97280048a0b8119a9
parent 432738 3bfde35a0d18a643485ffd5073f3bc6a79e0ae48
child 432785 a86ad1d51eb92bfed2170d21429b289fcc8d5105
push id34422
push userahalberstadt@mozilla.com
push dateWed, 02 Nov 2016 19:47:10 +0000
reviewersted
bugs1020516
milestone52.0a1
Bug 1020516 - Pass options.quiet into mochitest MessageLogger via constructor, r?ted For some reason we have a 'buffering' parameter in the MessageLogger constructor, but then rather than using this, the mochitest harness modifies state after instantiation. Using the constructor is easier to understand, and simplifies some of the logic in the next couple of patches. MozReview-Commit-ID: Jkd9hOlmiGZ
testing/mochitest/runtests.py
testing/mochitest/runtestsremote.py
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -85,17 +85,16 @@ here = os.path.abspath(os.path.dirname(_
 ########################################
 
 # Set the desired log modules you want a log be produced
 # by a try run for, or leave blank to disable the feature.
 # This will be passed to MOZ_LOG environment variable.
 # Try run will then put a download link for all log files
 # on tbpl.mozilla.org.
 
-# MOZ_LOG = "signaling:3,mtransport:4,DataChannel:4,jsep:4,MediaPipelineFactory:4"
 MOZ_LOG = ""
 
 #####################
 # Test log handling #
 #####################
 
 # output processing
 
@@ -766,17 +765,17 @@ class MochitestDesktop(object):
     sslTunnel = None
     DEFAULT_TIMEOUT = 60.0
     mediaDevices = None
 
     # XXX use automation.py for test name to avoid breaking legacy
     # TODO: replace this with 'runtests.py' or 'mochitest' or the like
     test_name = 'automation.py'
 
-    def __init__(self, logger_options):
+    def __init__(self, logger_options, quiet=False):
         self.update_mozinfo()
         self.server = None
         self.wsserver = None
         self.websocketProcessBridge = None
         self.sslTunnel = None
         self._active_tests = None
         self._locations = None
 
@@ -792,17 +791,17 @@ class MochitestDesktop(object):
                 "Mochitest specific tbpl formatter")
             self.log = commandline.setup_logging("mochitest",
                                                  logger_options,
                                                  {
                                                      "tbpl": sys.stdout
                                                  })
             MochitestDesktop.log = self.log
 
-        self.message_logger = MessageLogger(logger=self.log)
+        self.message_logger = MessageLogger(logger=self.log, buffering=quiet)
         # Max time in seconds to wait for server startup before tests will fail -- if
         # this seems big, it's mostly for debug machines where cold startup
         # (particularly after a build) takes forever.
         self.SERVER_STARTUP_TIMEOUT = 180 if mozinfo.info.get('debug') else 90
 
         # metro browser sub process id
         self.browserProcessId = None
 
@@ -1868,27 +1867,22 @@ toolbar#nav-bar {
                valgrindPath=None,
                valgrindArgs=None,
                valgrindSuppFiles=None,
                symbolsPath=None,
                timeout=-1,
                detectShutdownLeaks=False,
                screenshotOnFail=False,
                bisectChunk=None,
-               quiet=False,
                marionette_args=None):
         """
         Run the app, log the duration it took to execute, return the status code.
         Kills the app if it runs for longer than |maxTime| seconds, or outputs nothing
         for |timeout| seconds.
         """
-
-        # configure the message logger buffering
-        self.message_logger.buffering = quiet
-
         # It can't be the case that both a with-debugger and an
         # on-Valgrind run have been requested.  doTests() should have
         # already excluded this possibility.
         assert not(valgrindPath and debuggerInfo)
 
         # debugger information
         interactive = False
         debug_args = None
@@ -2391,17 +2385,16 @@ toolbar#nav-bar {
                                  valgrindPath=valgrindPath,
                                  valgrindArgs=valgrindArgs,
                                  valgrindSuppFiles=valgrindSuppFiles,
                                  symbolsPath=options.symbolsPath,
                                  timeout=timeout,
                                  detectShutdownLeaks=detectShutdownLeaks,
                                  screenshotOnFail=options.screenshotOnFail,
                                  bisectChunk=options.bisectChunk,
-                                 quiet=options.quiet,
                                  marionette_args=marionette_args,
                                  )
         except KeyboardInterrupt:
             self.log.info("runtests.py | Received keyboard interrupt.\n")
             status = -1
         except:
             traceback.print_exc()
             self.log.error(
@@ -2655,17 +2648,17 @@ toolbar#nav-bar {
 
 def run_test_harness(parser, options):
     parser.validate(options)
 
     logger_options = {
         key: value for key, value in vars(options).iteritems()
         if key.startswith('log') or key == 'valgrind'}
 
-    runner = MochitestDesktop(logger_options)
+    runner = MochitestDesktop(logger_options, quiet=options.quiet)
 
     options.runByDir = False
 
     if options.flavor in ('plain', 'browser', 'chrome'):
         options.runByDir = True
 
     result = runner.runTests(options)
 
--- a/testing/mochitest/runtestsremote.py
+++ b/testing/mochitest/runtestsremote.py
@@ -282,17 +282,16 @@ class MochiRemote(MochitestDesktop):
 
         # automation.py/remoteautomation `runApp` takes the profile path,
         # whereas runtest.py's `runApp` takes a mozprofile object.
         if 'profileDir' not in kwargs and 'profile' in kwargs:
             kwargs['profileDir'] = kwargs.pop('profile').profile
 
         # remove args not supported by automation.py
         kwargs.pop('marionette_args', None)
-        kwargs.pop('quiet', None)
 
         return self._automation.runApp(*args, **kwargs)
 
 
 def run_test_harness(parser, options):
     parser.validate(options)
 
     message_logger = MessageLogger(logger=None)