Bug 1546100 - [mochitest] Use kwargs from moztest.resolve in mach mochitest, r=jmaher
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Fri, 26 Apr 2019 12:45:38 +0000
changeset 530384 e47482b63074eaa04e31c74835a91c89a504afb8
parent 530383 38a860da33822840712ea52dc1fe2c07eab05287
child 530385 ce1c928fb0cd091b7d0dd3eea71a0d97bf0ac474
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjmaher
bugs1546100
milestone68.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 1546100 - [mochitest] Use kwargs from moztest.resolve in mach mochitest, r=jmaher These days 'moztest.resolve' is becoming the defacto place to define test harness related metadata. Currently |mach test| uses it to find kwargs that need to get set for mochitest commands, but |mach mochitest| does not. Instead, it grabs this metadata from 'mochitest_options.py'. This patch makes the kwargs used consistent between both |mach test| and |mach mochitest|. Differential Revision: https://phabricator.services.mozilla.com/D28537
testing/mochitest/mach_commands.py
testing/mochitest/mochitest_options.py
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -100,22 +100,18 @@ class MochitestRunner(MozbuildObject):
         if test_objects:
             return test_objects
 
         from moztest.resolve import TestResolver
         resolver = self._spawn(TestResolver)
         tests = list(resolver.resolve_tests(paths=test_paths, cwd=cwd))
         return tests
 
-    def run_desktop_test(self, context, tests=None, suite=None, **kwargs):
-        """Runs a mochitest.
-
-        suite is the type of mochitest to run. It can be one of ('plain',
-        'chrome', 'browser', 'a11y').
-        """
+    def run_desktop_test(self, context, tests=None, **kwargs):
+        """Runs a mochitest."""
         # runtests.py is ambiguous, so we load the file/module manually.
         if 'mochitest' not in sys.modules:
             import imp
             path = os.path.join(self.mochitest_dir, 'runtests.py')
             with open(path, 'r') as fh:
                 imp.load_module('mochitest', fh, path,
                                 ('.py', 'r', imp.PY_SOURCE))
 
@@ -139,26 +135,26 @@ class MochitestRunner(MozbuildObject):
             manifest = TestManifest()
             manifest.tests.extend(tests)
             options.manifestFile = manifest
 
             # When developing mochitest-plain tests, it's often useful to be able to
             # refresh the page to pick up modifications. Therefore leave the browser
             # open if only running a single mochitest-plain test. This behaviour can
             # be overridden by passing in --keep-open=false.
-            if len(tests) == 1 and options.keep_open is None and suite == 'plain':
+            if len(tests) == 1 and options.keep_open is None and options.flavor == 'plain':
                 options.keep_open = True
 
         # We need this to enable colorization of output.
         self.log_manager.enable_unstructured()
         result = mochitest.run_test_harness(parser, options)
         self.log_manager.disable_unstructured()
         return result
 
-    def run_android_test(self, context, tests, suite=None, **kwargs):
+    def run_android_test(self, context, tests, **kwargs):
         host_ret = verify_host_bin()
         if host_ret != 0:
             return host_ret
 
         import imp
         path = os.path.join(self.mochitest_dir, 'runtestsremote.py')
         with open(path, 'r') as fh:
             imp.load_module('runtestsremote', fh, path,
@@ -188,17 +184,17 @@ class MochitestRunner(MozbuildObject):
         host_ret = verify_host_bin()
         if host_ret != 0:
             return host_ret
 
         import runjunit
         options = Namespace(**kwargs)
         return runjunit.run_test_harness(parser, options)
 
-    def run_robocop_test(self, context, tests, suite=None, **kwargs):
+    def run_robocop_test(self, context, tests, **kwargs):
         host_ret = verify_host_bin()
         if host_ret != 0:
             return host_ret
 
         import imp
         path = os.path.join(self.mochitest_dir, 'runrobocop.py')
         with open(path, 'r') as fh:
             imp.load_module('runrobocop', fh, path,
@@ -327,16 +323,17 @@ class MachCommands(MachCommandBase):
     @Command('mochitest', category='testing',
              conditions=[is_buildapp_in(*SUPPORTED_APPS)],
              description='Run any flavor of mochitest (integration test).',
              parser=setup_argument_parser)
     def run_mochitest_general(self, flavor=None, test_objects=None, resolve_tests=True, **kwargs):
         from mochitest_options import ALL_FLAVORS
         from mozlog.commandline import setup_logging
         from mozlog.handlers import StreamHandler
+        from moztest.resolve import get_suite_definition
 
         buildapp = None
         for app in SUPPORTED_APPS:
             if is_buildapp_in(app)(self):
                 buildapp = app
                 break
 
         flavors = None
@@ -460,26 +457,26 @@ class MachCommands(MachCommandBase):
                                   app=app, device_serial=device_serial)
             grant_runtime_permissions(self, app, device_serial=device_serial)
             run_mochitest = mochitest.run_android_test
         else:
             run_mochitest = mochitest.run_desktop_test
 
         overall = None
         for (flavor, subsuite), tests in sorted(suites.items()):
-            fobj = ALL_FLAVORS[flavor]
+            _, suite = get_suite_definition(flavor, subsuite)
+            if 'test_paths' in suite['kwargs']:
+                del suite['kwargs']['test_paths']
 
             harness_args = kwargs.copy()
-            harness_args['subsuite'] = subsuite
-            harness_args.update(fobj.get('extra_args', {}))
+            harness_args.update(suite['kwargs'])
 
             result = run_mochitest(
                 self._mach_context,
                 tests=tests,
-                suite=fobj['suite'],
                 **harness_args)
 
             if result:
                 overall = result
 
             # Halt tests on keyboard interrupt
             if result == -1:
                 break
--- a/testing/mochitest/mochitest_options.py
+++ b/testing/mochitest/mochitest_options.py
@@ -639,16 +639,21 @@ class MochitestArguments(ArgumentContain
             if not os.path.exists(options.app):
                 parser.error("Error: Path {} doesn't exist. Are you executing "
                              "$objdir/_tests/testing/mochitest/runtests.py?".format(
                                  options.app))
 
         if options.flavor is None:
             options.flavor = 'plain'
 
+        for value in ALL_FLAVORS.values():
+            if options.flavor in value['aliases']:
+                options.flavor = value['suite']
+                break
+
         if options.gmp_path is None and options.app and build_obj:
             # Need to fix the location of gmp_fake which might not be shipped in the binary
             gmp_modules = (
                 ('gmp-fake', '1.0'),
                 ('gmp-clearkey', '0.1'),
                 ('gmp-fakeopenh264', '1.0')
             )
             options.gmp_path = os.pathsep.join(