Bug 1413928 - [mozharness] Accept extra test harness args via environment variable r=maja_zf
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Thu, 02 Nov 2017 15:53:39 -0400
changeset 453999 7056a096843a0c89ae2c6e00818b0603372e3334
parent 453983 89cb08844b17eef5f75984b22417b5bf6aad802a
child 454000 7ee4038b46285cd8111479ffef1313f0ee5bd8f4
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1413928
milestone59.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 1413928 - [mozharness] Accept extra test harness args via environment variable r=maja_zf When MOZHARNESS_TEST_PATHS is set, the test suite mozharness scripts will run the paths specified there instead of the normal chunking and/or default manifest. Paths should be separated by a ':' character. In the case of web_platform_tests.py, we have to make the test paths relative to 'testing/web-platform'. MozReview-Commit-ID: IHRXXi5mB4G
testing/mozharness/scripts/android_emulator_unittest.py
testing/mozharness/scripts/desktop_unittest.py
testing/mozharness/scripts/marionette.py
testing/mozharness/scripts/web_platform_tests.py
--- a/testing/mozharness/scripts/android_emulator_unittest.py
+++ b/testing/mozharness/scripts/android_emulator_unittest.py
@@ -458,33 +458,38 @@ class AndroidEmulatorTest(BlobUploadMixi
             # marionette options
             'address': c.get('marionette_address'),
             'gecko_log': os.path.join(dirs["abs_blob_upload_dir"], 'gecko.log'),
             'test_manifest': os.path.join(
                 dirs['abs_marionette_tests_dir'],
                 self.config.get('marionette_test_manifest', '')
             ),
         }
+
+        user_paths = os.environ.get('MOZHARNESS_TEST_PATHS')
         for option in self.config["suite_definitions"][self.test_suite]["options"]:
             opt = option.split('=')[0]
             # override configured chunk options with script args, if specified
-            if opt == '--this-chunk' and self.this_chunk is not None:
-                continue
-            if opt == '--total-chunks' and self.total_chunks is not None:
-                continue
+            if opt in ('--this-chunk', '--total-chunks'):
+                if user_paths or getattr(self, opt.replace('-', '_').strip('_'), None) is not None:
+                    continue
+
             if '%(app)' in option:
                 # only query package name if requested
                 cmd.extend([option % {'app': self._query_package_name()}])
             else:
                 cmd.extend([option % str_format_values])
 
-        if self.this_chunk is not None:
-            cmd.extend(['--this-chunk', self.this_chunk])
-        if self.total_chunks is not None:
-            cmd.extend(['--total-chunks', self.total_chunks])
+        if user_paths:
+            cmd.extend(user_paths.split(':'))
+        else:
+            if self.this_chunk is not None:
+                cmd.extend(['--this-chunk', self.this_chunk])
+            if self.total_chunks is not None:
+                cmd.extend(['--total-chunks', self.total_chunks])
 
         try_options, try_tests = self.try_args(self.test_suite)
         cmd.extend(try_options)
         if self.config.get('verify') is not True:
             cmd.extend(self.query_tests_args(
                 self.config["suite_definitions"][self.test_suite].get("tests"),
                 None,
                 try_tests))
--- a/testing/mozharness/scripts/desktop_unittest.py
+++ b/testing/mozharness/scripts/desktop_unittest.py
@@ -410,17 +410,20 @@ class DesktopUnittest(TestingMixin, Merc
                 str_format_values['symbols_path'] = self.symbols_path
 
             if suite_category not in SUITE_NO_E10S:
                 if suite_category in SUITE_DEFAULT_E10S and not c['e10s']:
                     base_cmd.append('--disable-e10s')
                 elif suite_category not in SUITE_DEFAULT_E10S and c['e10s']:
                     base_cmd.append('--e10s')
 
-            if c.get('total_chunks') and c.get('this_chunk'):
+            # Ignore chunking if we have user specified test paths
+            if os.environ.get('MOZHARNESS_TEST_PATHS'):
+                base_cmd.extend(os.environ['MOZHARNESS_TEST_PATHS'].split(':'))
+            elif c.get('total_chunks') and c.get('this_chunk'):
                 base_cmd.extend(['--total-chunks', c['total_chunks'],
                                  '--this-chunk', c['this_chunk']])
 
             if c['no_random']:
                 if suite_category == "mochitest":
                     base_cmd.append('--bisect-chunk=default')
                 else:
                     self.warning("--no-random does not currently work with suites other than "
--- a/testing/mozharness/scripts/marionette.py
+++ b/testing/mozharness/scripts/marionette.py
@@ -307,17 +307,20 @@ class MarionetteTest(TestingMixin, Mercu
 
         for arg in self.config["suite_definitions"][self.test_suite]["options"]:
             cmd.append(arg % config_fmt_args)
 
         if self.mkdir_p(dirs["abs_blob_upload_dir"]) == -1:
             # Make sure that the logging directory exists
             self.fatal("Could not create blobber upload directory")
 
-        cmd.append(manifest)
+        if os.environ.get('MOZHARNESS_TEST_PATHS'):
+            cmd.extend(os.environ['MOZHARNESS_TEST_PATHS'].split(':'))
+        else:
+            cmd.append(manifest)
 
         try_options, try_tests = self.try_args("marionette")
         cmd.extend(self.query_tests_args(try_tests,
                                          str_format_values=config_fmt_args))
 
         env = {}
         if self.query_minidump_stackwalk():
             env['MINIDUMP_STACKWALK'] = self.minidump_stackwalk_path
--- a/testing/mozharness/scripts/web_platform_tests.py
+++ b/testing/mozharness/scripts/web_platform_tests.py
@@ -219,20 +219,27 @@ class WebPlatformTest(TestingMixin, Merc
         if not c["e10s"]:
             cmd.append("--disable-e10s")
 
         if c["single_stylo_traversal"]:
             cmd.append("--stylo-threads=1")
         else:
             cmd.append("--stylo-threads=4")
 
-        for opt in ["total_chunks", "this_chunk"]:
-            val = c.get(opt)
-            if val:
-                cmd.append("--%s=%s" % (opt.replace("_", "-"), val))
+        if os.environ.get('MOZHARNESS_TEST_PATHS'):
+            prefix = 'testing/web-platform'
+            paths = os.environ['MOZHARNESS_TEST_PATHS'].split(':')
+            paths = [os.path.join(dirs["abs_wpttest_dir"], os.path.relpath(p, prefix))
+                     for p in paths if p.startswith(prefix)]
+            cmd.extend(paths)
+        else:
+            for opt in ["total_chunks", "this_chunk"]:
+                val = c.get(opt)
+                if val:
+                    cmd.append("--%s=%s" % (opt.replace("_", "-"), val))
 
         if "wdspec" in test_types:
             geckodriver_path = self._query_geckodriver()
             if not geckodriver_path or not os.path.isfile(geckodriver_path):
                 self.fatal("Unable to find geckodriver binary "
                            "in common test package: %s" % str(geckodriver_path))
             cmd.append("--webdriver-binary=%s" % geckodriver_path)