Bug 1242083 - Add --setenv to the arguments accepted by mozharness to pass to the harness command, add a way to specify flavors an argument applies to. r=armenzg
authorChris Manchester <cmanchester@mozilla.com>
Fri, 05 Feb 2016 16:57:36 -0800
changeset 283246 f0b059e04fa4432de9f9f8677e9553d08712a926
parent 283245 301dc955251397607077f490f3a8af488df3110b
child 283247 9fd35286b835f170f95acd71a2e335716e8424d2
push id71486
push usercmanchester@mozilla.com
push dateSat, 06 Feb 2016 00:57:40 +0000
treeherdermozilla-inbound@f0b059e04fa4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersarmenzg
bugs1242083
milestone47.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 1242083 - Add --setenv to the arguments accepted by mozharness to pass to the harness command, add a way to specify flavors an argument applies to. r=armenzg
testing/mozharness/mozharness/mozilla/testing/try_tools.py
--- a/testing/mozharness/mozharness/mozilla/testing/try_tools.py
+++ b/testing/mozharness/mozharness/mozilla/testing/try_tools.py
@@ -41,21 +41,42 @@ test_flavors = {
 
 class TryToolsMixin(TransferMixin):
     """Utility functions for an interface between try syntax and out test harnesses.
     Requires log and script mixins."""
 
     harness_extra_args = None
     try_test_paths = {}
     known_try_arguments = {
-        '--tag': {
+        '--tag': ({
             'action': 'append',
             'dest': 'tags',
             'default': None,
-        },
+        }, (
+            'browser-chrome',
+            'chrome',
+            'devtools-chrome',
+            'marionette',
+            'mochitest',
+            'web-plaftform-tests',
+            'xpcshell',
+        )),
+        '--setenv': ({
+            'action': 'append',
+            'dest': 'setenv',
+            'default': [],
+            'metavar': 'NAME=VALUE',
+        }, (
+            'browser-chrome',
+            'chrome',
+            'crashtest',
+            'devtools-chrome',
+            'mochitest',
+            'reftest',
+        )),
     }
 
     def _extract_try_message(self):
         msg = None
         if "try_message" in self.config and self.config["try_message"]:
             msg = self.config["try_message"]
         else:
             if self.buildbot_config['sourcestamp']['changes']:
@@ -119,63 +140,67 @@ class TryToolsMixin(TransferMixin):
                          ' and forward them to the underlying test harness command.'))
 
         label_dict = {}
         def label_from_val(val):
             if val in label_dict:
                 return label_dict[val]
             return '--%s' % val.replace('_', '-')
 
-        for label, opts in self.known_try_arguments.iteritems():
+        for label, (opts, _) in self.known_try_arguments.iteritems():
             if 'action' in opts and opts['action'] not in ('append', 'store',
                                                            'store_true', 'store_false'):
                 self.fatal('Try syntax does not support passing custom or store_const '
                            'arguments to the harness process.')
             if 'dest' in opts:
                 label_dict[opts['dest']] = label
 
             parser.add_argument(label, **opts)
 
         parser.add_argument('--try-test-paths', nargs='*')
         (args, _) = parser.parse_known_args(all_try_args)
         self.try_test_paths = self._group_test_paths(args.try_test_paths)
         del args.try_test_paths
 
-        out_args = []
+        out_args = defaultdict(list)
         # This is a pretty hacky way to echo arguments down to the harness.
         # Hopefully this can be improved once we have a configuration system
         # in tree for harnesses that relies less on a command line.
-        for (arg, value) in vars(args).iteritems():
+        for arg, value in vars(args).iteritems():
             if value:
                 label = label_from_val(arg)
-                if isinstance(value, bool):
-                    # A store_true or store_false argument.
-                    out_args.append(label)
-                elif isinstance(value, list):
-                    out_args.extend(['%s=%s' % (label, el) for el in value])
-                else:
-                    out_args.append('%s=%s' % (label, value))
+                _, flavors = self.known_try_arguments[label]
 
-        self.harness_extra_args = out_args
+                for f in flavors:
+                    if isinstance(value, bool):
+                        # A store_true or store_false argument.
+                        out_args[f].append(label)
+                    elif isinstance(value, list):
+                        out_args[f].extend(['%s=%s' % (label, el) for el in value])
+                    else:
+                        out_args[f].append('%s=%s' % (label, value))
+
+        self.harness_extra_args = dict(out_args)
 
     def _group_test_paths(self, args):
         rv = defaultdict(list)
 
         if args is None:
             return rv
 
         for item in args:
             suite, path = item.split(":", 1)
             rv[suite].append(path)
         return rv
 
     def try_args(self, flavor):
         """Get arguments, test_list derived from try syntax to apply to a command"""
-        # TODO: Detect and reject incompatible arguments
-        args = self.harness_extra_args[:] if self.harness_extra_args else []
+        args = []
+        if self.harness_extra_args:
+            args = self.harness_extra_args.get(flavor, [])[:]
 
         if self.try_test_paths.get(flavor):
             self.info('TinderboxPrint: Tests will be run from the following '
                       'files: %s.' % ','.join(self.try_test_paths[flavor]))
             args.extend(['--this-chunk=1', '--total-chunks=1'])
 
             path_func = test_flavors[flavor].get("path", lambda x:x)
             tests = [path_func(item) for item in self.try_test_paths[flavor]]