Bug 1399956 - Add headless flag for mochitests. r?jmaher draft
authorBrendan Dahl <brendan.dahl@gmail.com>
Tue, 26 Sep 2017 13:27:04 -0700
changeset 677770 a2f8ed82a4195b1233399d369ae1854990ae2669
parent 677769 8ade235c6d31692e2ad0a7d7a6ab8a491df0b160
child 677771 067988b9790219c0a772a0e89c3e556497d14906
push id83803
push userbmo:bdahl@mozilla.com
push dateTue, 10 Oct 2017 18:53:32 +0000
reviewersjmaher
bugs1399956
milestone58.0a1
Bug 1399956 - Add headless flag for mochitests. r?jmaher MozReview-Commit-ID: Kqk0sw4ykEm
testing/mochitest/mochitest_options.py
testing/mochitest/runtests.py
--- a/testing/mochitest/mochitest_options.py
+++ b/testing/mochitest/mochitest_options.py
@@ -469,16 +469,22 @@ class MochitestArguments(ArgumentContain
                   "for storing the screenshots."
           }],
         [["--quiet"],
          {"action": "store_true",
           "dest": "quiet",
           "default": False,
           "help": "Do not print test log lines unless a failure occurs.",
           }],
+        [["--headless"],
+         {"action": "store_true",
+          "dest": "headless",
+          "default": False,
+          "help": "Run tests in headless mode.",
+          }],
         [["--pidfile"],
          {"dest": "pidFile",
           "default": "",
           "help": "Name of the pidfile to generate.",
           "suppress": True,
           }],
         [["--use-test-media-devices"],
          {"action": "store_true",
--- a/testing/mochitest/runtests.py
+++ b/testing/mochitest/runtests.py
@@ -1608,16 +1608,19 @@ toolbar#nav-bar {
             lsanPath=lsanPath,
             ubsanPath=ubsanPath)
 
         if hasattr(options, "topsrcdir"):
             browserEnv["MOZ_DEVELOPER_REPO_DIR"] = options.topsrcdir
         if hasattr(options, "topobjdir"):
             browserEnv["MOZ_DEVELOPER_OBJ_DIR"] = options.topobjdir
 
+        if options.headless:
+            browserEnv["MOZ_HEADLESS"] = '1'
+
         # These variables are necessary for correct application startup; change
         # via the commandline at your own risk.
         browserEnv["XPCOM_DEBUG_BREAK"] = "stack"
 
         # interpolate environment passed with options
         try:
             browserEnv.update(
                 dict(
@@ -2402,16 +2405,17 @@ toolbar#nav-bar {
     def runTests(self, options):
         """ Prepare, configure, run tests and cleanup """
 
         # a11y and chrome tests don't run with e10s enabled in CI. Need to set
         # this here since |mach mochitest| sets the flavor after argument parsing.
         if options.flavor in ('a11y', 'chrome'):
             options.e10s = False
         mozinfo.update({"e10s": options.e10s})  # for test manifest parsing.
+        mozinfo.update({"headless": options.headless})  # for test manifest parsing.
 
         if options.jscov_dir_prefix is not None:
             mozinfo.update({'coverage': True})
 
         self.setTestRoot(options)
 
         # Despite our efforts to clean up servers started by this script, in practice
         # we still see infrequent cases where a process is orphaned and interferes