From 811da0a366e3b3df5524864f1aaa31fd53a2549f Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Thu, 2 Nov 2017 15:53:39 -0400 Subject: [PATCH] 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 --HG-- extra : rebase_source : 17b31ec19a64ab16918d0bd80d19d9bb496cbe37 --- .../scripts/android_emulator_unittest.py | 21 ++++++++++++------- .../mozharness/scripts/desktop_unittest.py | 5 ++++- testing/mozharness/scripts/marionette.py | 5 ++++- .../mozharness/scripts/web_platform_tests.py | 15 +++++++++---- 4 files changed, 32 insertions(+), 14 deletions(-) diff --git a/testing/mozharness/scripts/android_emulator_unittest.py b/testing/mozharness/scripts/android_emulator_unittest.py index be73074109bc..c6329db29ebc 100644 --- a/testing/mozharness/scripts/android_emulator_unittest.py +++ b/testing/mozharness/scripts/android_emulator_unittest.py @@ -463,23 +463,28 @@ class AndroidEmulatorTest(BlobUploadMixin, TestingMixin, EmulatorMixin, VCSMixin 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) diff --git a/testing/mozharness/scripts/desktop_unittest.py b/testing/mozharness/scripts/desktop_unittest.py index 5e067c78036b..91eeb8bfae05 100755 --- a/testing/mozharness/scripts/desktop_unittest.py +++ b/testing/mozharness/scripts/desktop_unittest.py @@ -415,7 +415,10 @@ class DesktopUnittest(TestingMixin, MercurialScript, BlobUploadMixin, MozbaseMix 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']]) diff --git a/testing/mozharness/scripts/marionette.py b/testing/mozharness/scripts/marionette.py index 54d5c76c66a1..303a01f77617 100755 --- a/testing/mozharness/scripts/marionette.py +++ b/testing/mozharness/scripts/marionette.py @@ -312,7 +312,10 @@ class MarionetteTest(TestingMixin, MercurialScript, BlobUploadMixin, TransferMix # 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, diff --git a/testing/mozharness/scripts/web_platform_tests.py b/testing/mozharness/scripts/web_platform_tests.py index c9f51dfac81a..98b92e4ce84b 100755 --- a/testing/mozharness/scripts/web_platform_tests.py +++ b/testing/mozharness/scripts/web_platform_tests.py @@ -224,10 +224,17 @@ class WebPlatformTest(TestingMixin, MercurialScript, BlobUploadMixin, CodeCovera 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()