Bug 1089536 - Allow multiple test variable files to be specified on the command line. r=mdas
authorDave Hunt <dhunt@mozilla.com>
Tue, 18 Nov 2014 13:34:46 +0000
changeset 240594 2e541f48b3c8efc53c555cfed5d66c067848c761
parent 240593 e19b12356553319722101fdbda356682a59786ec
child 240595 bf73bf22dfba714bc4de5e9a5e5095f07ef21bd3
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmdas
bugs1089536
milestone36.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 1089536 - Allow multiple test variable files to be specified on the command line. r=mdas
testing/marionette/client/marionette/runner/base.py
--- a/testing/marionette/client/marionette/runner/base.py
+++ b/testing/marionette/client/marionette/runner/base.py
@@ -327,17 +327,17 @@ class BaseMarionetteOptions(OptionParser
                         default=0,
                         help='number of times to repeat the test(s)')
         self.add_option('-x', '--xml-output',
                         action='store',
                         dest='xml_output',
                         help='xml output')
         self.add_option('--testvars',
                         dest='testvars',
-                        action='store',
+                        action='append',
                         help='path to a json file with any test data required')
         self.add_option('--tree',
                         dest='tree',
                         action='store',
                         default='b2g',
                         help='the tree that the revision parameter refers to')
         self.add_option('--symbols-path',
                         dest='symbols_path',
@@ -468,17 +468,16 @@ class BaseMarionetteTestRunner(object):
         self.logger = logger
         self.no_window = no_window
         self.httpd = None
         self.marionette = None
         self.logdir = logdir
         self.logcat_stdout = logcat_stdout
         self.xml_output = xml_output
         self.repeat = repeat
-        self.testvars = {}
         self.test_kwargs = kwargs
         self.tree = tree
         self.type = type
         self.device_serial = device_serial
         self.symbols_path = symbols_path
         self.timeout = timeout
         self._device = None
         self._capabilities = None
@@ -509,27 +508,39 @@ class BaseMarionetteTestRunner(object):
                     rv['source'] = marionette.page_source
                 except:
                     logger = get_default_logger()
                     logger.warning('Failed to gather test failure debug.', exc_info=True)
             return rv
 
         self.result_callbacks.append(gather_debug)
 
-        if testvars:
-            if not os.path.exists(testvars):
-                raise IOError('--testvars file does not exist')
+        def update(d, u):
+            """ Update a dictionary that may contain nested dictionaries. """
+            for k, v in u.iteritems():
+                o = d.get(k, {})
+                if isinstance(v, dict) and isinstance(o, dict):
+                    d[k] = update(d.get(k, {}), v)
+                else:
+                    d[k] = u[k]
+            return d
 
-            try:
-                with open(testvars) as f:
-                    self.testvars = json.loads(f.read())
-            except ValueError as e:
-                json_path = os.path.abspath(testvars)
-                raise Exception("JSON file (%s) is not properly "
-                                "formatted: %s" % (json_path, e.message))
+        self.testvars = {}
+        if testvars is not None:
+            for path in list(testvars):
+                if not os.path.exists(path):
+                    raise IOError('--testvars file %s does not exist' % path)
+                try:
+                    with open(path) as f:
+                        self.testvars = update(self.testvars,
+                                               json.loads(f.read()))
+                except ValueError as e:
+                    raise Exception("JSON file (%s) is not properly "
+                                    "formatted: %s" % (os.path.abspath(path),
+                                                       e.message))
 
         # set up test handlers
         self.test_handlers = []
 
         self.reset_test_stats()
 
         if self.logdir:
             if not os.access(self.logdir, os.F_OK):