Bug 1036869 - Make mach accept structured logging command line arguments for marionette.;r=jgraham
authorChris Manchester <cmanchester@mozilla.com>
Thu, 17 Jul 2014 21:28:45 -0400
changeset 194800 c6886d31a30be5c3da61c6d213aea17295ec213c
parent 194799 c361be2aeb66ec71289f34a5edfcc7a2527afbf8
child 194801 39de47827a38c006650672c8a08d57a1a8482316
push id27157
push userryanvm@gmail.com
push dateFri, 18 Jul 2014 19:00:26 +0000
treeherdermozilla-central@ecdb409898a6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgraham
bugs1036869
milestone33.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 1036869 - Make mach accept structured logging command line arguments for marionette.;r=jgraham
testing/marionette/mach_commands.py
--- a/testing/marionette/mach_commands.py
+++ b/testing/marionette/mach_commands.py
@@ -1,18 +1,19 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import unicode_literals
 
 import os
 import sys
+import argparse
 
-from mozlog import structured
+from mozlog.structured import commandline
 
 from mozbuild.base import (
     MachCommandBase,
     MachCommandConditions as conditions,
 )
 
 from mach.decorators import (
     CommandArgument,
@@ -24,25 +25,30 @@ MARIONETTE_DISABLED_B2G = '''
 The %s command requires a Marionette-enabled build.
 
 Please create an engineering build, which has Marionette enabled.  You can do
 this by ommitting the VARIANT variable when building, or using:
 
 VARIANT=eng ./build.sh
 '''
 
+# A parser that will accept structured logging commandline arguments.
+_parser = argparse.ArgumentParser()
+commandline.add_logging_group(_parser)
+
 def run_marionette(tests, b2g_path=None, emulator=None, testtype=None,
-    address=None, binary=None, topsrcdir=None):
+    address=None, binary=None, topsrcdir=None, **kwargs):
     from marionette.runtests import (
         MarionetteTestRunner,
         BaseMarionetteOptions,
         startTestRunner
     )
 
     parser = BaseMarionetteOptions()
+    commandline.add_logging_group(parser)
     options, args = parser.parse_args()
 
     if not tests:
         tests = [os.path.join(topsrcdir,
                     'testing/marionette/client/marionette/tests/unit-tests.ini')]
 
     options.type = testtype
     if b2g_path:
@@ -52,19 +58,19 @@ def run_marionette(tests, b2g_path=None,
     else:
         options.binary = binary
         path, exe = os.path.split(options.binary)
 
     options.address = address
 
     parser.verify_usage(options, tests)
 
-    options.logger = structured.commandline.setup_logging("Marionette Unit Tests",
-                                                          options,
-                                                          {"mach": sys.stdout})
+    options.logger = commandline.setup_logging("Marionette Unit Tests",
+                                               options,
+                                               {"mach": sys.stdout})
 
     runner = startTestRunner(MarionetteTestRunner, options, tests)
     if runner.failed > 0:
         return 1
 
     return 0
 
 @CommandProvider
@@ -92,25 +98,27 @@ class B2GCommands(MachCommandBase):
 
         if self.substs.get('ENABLE_MARIONETTE') != '1':
             print(MARIONETTE_DISABLED_B2G % 'marionette-webapi')
             return 1
 
         return run_marionette(tests, b2g_path=self.b2g_home, emulator=emulator,
             testtype=testtype, topsrcdir=self.topsrcdir, address=None)
 
-
 @CommandProvider
 class MachCommands(MachCommandBase):
     @Command('marionette-test', category='testing',
         description='Run a Marionette test.',
-        conditions=[conditions.is_firefox])
+        conditions=[conditions.is_firefox],
+        parser=_parser,
+    )
     @CommandArgument('--address',
         help='host:port of running Gecko instance to connect to.')
     @CommandArgument('--type', dest='testtype',
         help='Test type, usually one of: browser, b2g, b2g-qemu.',
         default='browser')
     @CommandArgument('tests', nargs='*', metavar='TESTS',
         help='Path to test(s) to run.')
-    def run_marionette_test(self, tests, address=None, testtype=None):
+    def run_marionette_test(self, tests, address=None, testtype=None,
+                            **kwargs):
         binary = self.get_binary_path('app')
         return run_marionette(tests, binary=binary, testtype=testtype,
             topsrcdir=self.topsrcdir, address=address)