Bug 1255064 - MarionetteHarness should internally use dicts for arguments; r?maja_zf draft
authorRachel <rachel.b.king@gmail.com>
Fri, 18 Mar 2016 19:33:08 -0700
changeset 342701 39c3cf90cd16e3e21840f2ff6a499f26a635fd16
parent 341451 5cfc10c14aaea2a449f74dcbb366179a45442dd6
child 516608 a7582d1eb6a55037980e3f45c3b739b3f6e8de26
push id13444
push userbmo:rachel.b.king@gmail.com
push dateMon, 21 Mar 2016 01:16:42 +0000
reviewersmaja_zf
bugs1255064
milestone48.0a1
Bug 1255064 - MarionetteHarness should internally use dicts for arguments; r?maja_zf MozReview-Commit-ID: 94muKM44wVq
dom/media/test/external/mach_commands.py
testing/firefox-ui/mach_commands.py
testing/marionette/harness/marionette/runtests.py
testing/marionette/mach_commands.py
--- a/dom/media/test/external/mach_commands.py
+++ b/dom/media/test/external/mach_commands.py
@@ -45,17 +45,17 @@ def run_external_media_test(tests, testt
         setattr(args, k, v)
 
     parser.verify_usage(args)
 
     args.logger = commandline.setup_logging("Firefox External Media Tests",
                                             args,
                                             {"mach": sys.stdout})
     failed = mn_cli(MediaTestRunner, MediaTestArguments, FirefoxMediaHarness,
-                    args=args)
+                    args=vars(args))
 
     if failed > 0:
         return 1
     else:
         return 0
 
 
 @CommandProvider
--- a/testing/firefox-ui/mach_commands.py
+++ b/testing/firefox-ui/mach_commands.py
@@ -59,22 +59,17 @@ def run_firefox_ui_test(testtype=None, t
     # If no tests have been selected, set default ones
     if not kwargs.get('tests'):
         kwargs['tests'] = [os.path.join(fxui_dir, 'tests', test)
                            for test in test_types[testtype]['default_tests']]
 
     kwargs['logger'] = commandline.setup_logging('Firefox UI - {} Tests'.format(testtype),
                                                  {"mach": sys.stdout})
 
-    # Bug 1255064 - Marionette requieres an argparse Namespace. So fake one for now.
-    args = argparse.Namespace()
-    for k, v in kwargs.iteritems():
-        setattr(args, k, v)
-
-    failed = test_types[testtype]['cli_module'].cli(args=args)
+    failed = test_types[testtype]['cli_module'].cli(args=kwargs)
     if failed > 0:
         return 1
     else:
         return 0
 
 
 @CommandProvider
 class MachCommands(MachCommandBase):
--- a/testing/marionette/harness/marionette/runtests.py
+++ b/testing/marionette/harness/marionette/runtests.py
@@ -48,33 +48,34 @@ class MarionetteHarness(object):
         mozlog.commandline.add_logging_group(parser)
         args = parser.parse_args()
         parser.verify_usage(args)
 
         logger = mozlog.commandline.setup_logging(
             args.logger_name, args, logger_defaults or {"tbpl": sys.stdout})
 
         args.logger = logger
-        return args
+        return vars(args)
 
     def process_args(self):
-        if self.args.pydebugger:
-            MarionetteTestCase.pydebugger = __import__(self.args.pydebugger)
+        if self.args.get('pydebugger'):
+            MarionetteTestCase.pydebugger = __import__(self.args['pydebugger'])
 
     def run(self):
         try:
             self.process_args()
-            args_dict = vars(self.args)
-            tests = args_dict.pop('tests')
-            runner = self._runner_class(**args_dict)
+            tests = self.args.pop('tests')
+            runner = self._runner_class(**self.args)
             runner.run_tests(tests)
             return runner.failed
         except Exception:
-            self.args.logger.error('Failure during test execution.',
-                                   exc_info=True)
+            logger = self.args.get('logger')
+            if logger:
+                logger.error('Failure during test execution.',
+                                       exc_info=True)
             raise
 
 
 def cli(runner_class=MarionetteTestRunner, parser_class=MarionetteArguments,
         harness_class=MarionetteHarness, args=None):
     """
     Call the harness to parse args and run tests.
 
--- a/testing/marionette/mach_commands.py
+++ b/testing/marionette/mach_commands.py
@@ -62,17 +62,17 @@ def run_marionette(tests, b2g_path=None,
     for k, v in kwargs.iteritems():
         setattr(args, k, v)
 
     parser.verify_usage(args)
 
     args.logger = commandline.setup_logging("Marionette Unit Tests",
                                             args,
                                             {"mach": sys.stdout})
-    failed = MarionetteHarness(MarionetteTestRunner, args=args).run()
+    failed = MarionetteHarness(MarionetteTestRunner, args=vars(args)).run()
     if failed > 0:
         return 1
     else:
         return 0
 
 @CommandProvider
 class B2GCommands(MachCommandBase):
     def __init__(self, context):