Bug 1256996 - Firefox ui mach commands must call parse_args and verify_usage, with args as dict; r=maja_zf
authorGloria Guy <gloriaanholt@gmail.com>
Fri, 01 Apr 2016 17:30:56 -0700
changeset 291490 8e7f918c59ea2c82e3a72ce0aac3296e507983ce
parent 291489 873bdc9379fda4887e4a19bfc82998276e1a65d4
child 291491 84f8d2e0106c2c0da2855042abdf197d308db709
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1256996
milestone48.0a1
Bug 1256996 - Firefox ui mach commands must call parse_args and verify_usage, with args as dict; r=maja_zf MozReview-Commit-ID: 5ZmD3BTO3ws
testing/firefox-ui/mach_commands.py
--- a/testing/firefox-ui/mach_commands.py
+++ b/testing/firefox-ui/mach_commands.py
@@ -24,21 +24,24 @@ def setup_argument_parser_functional():
 
 
 def setup_argument_parser_update():
     from firefox_ui_harness.arguments.update import UpdateArguments
     return UpdateArguments()
 
 
 def run_firefox_ui_test(testtype=None, topsrcdir=None, **kwargs):
-    import argparse
-
     from mozlog.structured import commandline
     import firefox_ui_harness
 
+    if testtype == 'functional':
+        parser = setup_argument_parser_functional()
+    else:
+        parser = setup_argument_parser_update()
+
     test_types = {
         'functional': {
             'default_tests': [
                 os.path.join('puppeteer', 'manifest.ini'),
                 os.path.join('functional', 'manifest.ini'),
             ],
             'cli_module': firefox_ui_harness.cli_functional,
         },
@@ -52,24 +55,34 @@ def run_firefox_ui_test(testtype=None, t
 
     fxui_dir = os.path.join(topsrcdir, 'testing', 'firefox-ui')
 
     # Set the resources path which is used to serve test data via wptserve
     if not kwargs['server_root']:
         kwargs['server_root'] = os.path.join(fxui_dir, 'resources')
 
     # If no tests have been selected, set default ones
-    if not kwargs.get('tests'):
-        kwargs['tests'] = [os.path.join(fxui_dir, 'tests', test)
+    if kwargs.get('tests'):
+        tests = kwargs.get('tests')
+    else:
+        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})
 
-    failed = test_types[testtype]['cli_module'].cli(args=kwargs)
+    args = parser.parse_args(args=tests)
+
+    for k, v in kwargs.iteritems():
+        setattr(args, k, v)
+
+    parser.verify_usage(args)
+
+    failed = test_types[testtype]['cli_module'].cli(args=vars(args))
+
     if failed > 0:
         return 1
     else:
         return 0
 
 
 @CommandProvider
 class MachCommands(MachCommandBase):