Bug 999407 - add --setenv option for mochitests run through mach; r=jmaher
authorNathan Froyd <froydnj@mozilla.com>
Tue, 22 Apr 2014 09:09:47 -0400
changeset 179955 4d232ce4ffb53d5fe15b3d1849088a7841323462
parent 179954 22e57c335fc5bbd8e0b919c624e047106978536d
child 179956 0de0cedf6a7dd87c4a76a198243a5280402550b0
push id272
push userpvanderbeken@mozilla.com
push dateMon, 05 May 2014 16:31:18 +0000
reviewersjmaher
bugs999407
milestone31.0a1
Bug 999407 - add --setenv option for mochitests run through mach; r=jmaher DONTBUILD because NPOTB
testing/mochitest/mach_commands.py
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -185,17 +185,17 @@ class MochitestRunner(MozbuildObject):
 
     def run_desktop_test(self, context, suite=None, test_paths=None, debugger=None,
         debugger_args=None, slowscript=False, screenshot_on_fail = False, shuffle=False, keep_open=False,
         rerun_failures=False, no_autorun=False, repeat=0, run_until_failure=False,
         slow=False, chunk_by_dir=0, total_chunks=None, this_chunk=None,
         jsdebugger=False, debug_on_failure=False, start_at=None, end_at=None,
         e10s=False, dmd=False, dump_output_directory=None,
         dump_about_memory_after_test=False, dump_dmd_after_test=False,
-        install_extension=None, quiet=False, **kwargs):
+        install_extension=None, quiet=False, environment=[], **kwargs):
         """Runs a mochitest.
 
         test_paths are path to tests. They can be a relative path from the
         top source directory, an absolute filename, or a directory containing
         test files.
 
         suite is the type of mochitest to run. It can be one of ('plain',
         'chrome', 'browser', 'metro', 'a11y').
@@ -309,16 +309,17 @@ class MochitestRunner(MozbuildObject):
         options.debugOnFailure = debug_on_failure
         options.startAt = start_at
         options.endAt = end_at
         options.e10s = e10s
         options.dumpAboutMemoryAfterTest = dump_about_memory_after_test
         options.dumpDMDAfterTest = dump_dmd_after_test
         options.dumpOutputDirectory = dump_output_directory
         options.quiet = quiet
+        options.environment = environment
 
         options.failureFile = failure_file_path
         if install_extension != None:
             options.extensionsToInstall = [os.path.join(self.topsrcdir,install_extension)]
 
         for k, v in kwargs.iteritems():
             setattr(options, k, v)
 
@@ -510,16 +511,21 @@ def MochitestCommand(func):
         help='Install given extension before running selected tests. ' \
             'Parameter is a path to xpi file.')
     func = install_extension(func)
 
     quiet = CommandArgument('--quiet', default=False, action='store_true',
         help='Do not print test log lines unless a failure occurs.')
     func = quiet(func)
 
+    setenv = CommandArgument('--setenv', default=[], action='append',
+                             metavar='NAME=VALUE', dest='environment',
+                             help="Sets the given variable in the application's environment")
+    func = setenv(func)
+
     return func
 
 def B2GCommand(func):
     """Decorator that adds shared command arguments to b2g mochitest commands."""
 
     busybox = CommandArgument('--busybox', default=None,
         help='Path to busybox binary to install on device')
     func = busybox(func)