зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1550518 - Add --headless support for xpcshell-test. r=gbrown
Entries in the xpcshell.ini manifest override the default specified on the command line. Differential Revision: https://phabricator.services.mozilla.com/D70166 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
2a483b2bc4
Коммит
4d622e5e04
|
@ -161,6 +161,7 @@ class XPCShellTestThread(Thread):
|
|||
self.interactive = kwargs.get('interactive')
|
||||
self.prefsFile = kwargs.get('prefsFile')
|
||||
self.verboseIfFails = kwargs.get('verboseIfFails')
|
||||
self.headless = kwargs.get('headless')
|
||||
|
||||
# only one of these will be set to 1. adding them to the totals in
|
||||
# the harness
|
||||
|
@ -682,7 +683,7 @@ class XPCShellTestThread(Thread):
|
|||
if self.test_object.get('subprocess') == 'true':
|
||||
self.env['PYTHON'] = sys.executable
|
||||
|
||||
if self.test_object.get('headless', False):
|
||||
if self.test_object.get('headless', 'true' if self.headless else None) == 'true':
|
||||
self.env["MOZ_HEADLESS"] = '1'
|
||||
self.env["DISPLAY"] = '77' # Set a fake display.
|
||||
|
||||
|
@ -1397,6 +1398,7 @@ class XPCShellTests(object):
|
|||
self.threadCount = options.get('threadCount') or NUM_THREADS
|
||||
self.jscovdir = options.get('jscovdir')
|
||||
self.enable_webrender = options.get('enable_webrender')
|
||||
self.headless = options.get('headless')
|
||||
|
||||
self.testCount = 0
|
||||
self.passCount = 0
|
||||
|
@ -1485,6 +1487,7 @@ class XPCShellTests(object):
|
|||
'app_dir_key': appDirKey,
|
||||
'prefsFile': self.prefsFile,
|
||||
'verboseIfFails': self.verboseIfFails,
|
||||
'headless': self.headless,
|
||||
}
|
||||
|
||||
if self.sequential:
|
||||
|
|
|
@ -459,6 +459,26 @@ add_test(function test_child_mozinfo () {
|
|||
});
|
||||
'''
|
||||
|
||||
HEADLESS_TRUE = '''
|
||||
add_task(function headless_true() {
|
||||
let env = Cc["@mozilla.org/process/environment;1"].getService(
|
||||
Ci.nsIEnvironment
|
||||
);
|
||||
Assert.equal(env.get("MOZ_HEADLESS"), "1", "Check MOZ_HEADLESS");
|
||||
Assert.equal(env.get("DISPLAY"), "77", "Check DISPLAY");
|
||||
});
|
||||
'''
|
||||
|
||||
HEADLESS_FALSE = '''
|
||||
add_task(function headless_false() {
|
||||
let env = Cc["@mozilla.org/process/environment;1"].getService(
|
||||
Ci.nsIEnvironment
|
||||
);
|
||||
Assert.notEqual(env.get("MOZ_HEADLESS"), "1", "Check MOZ_HEADLESS");
|
||||
Assert.notEqual(env.get("DISPLAY"), "77", "Check DISPLAY");
|
||||
});
|
||||
'''
|
||||
|
||||
|
||||
class XPCShellTestsTests(unittest.TestCase):
|
||||
"""
|
||||
|
@ -513,7 +533,7 @@ tail =
|
|||
|
||||
""" + "\n".join(testlines))
|
||||
|
||||
def assertTestResult(self, expected, shuffle=False, verbose=False):
|
||||
def assertTestResult(self, expected, shuffle=False, verbose=False, headless=False):
|
||||
"""
|
||||
Assert that self.x.runTests with manifest=self.manifest
|
||||
returns |expected|.
|
||||
|
@ -525,6 +545,7 @@ tail =
|
|||
kwargs['mozInfo'] = mozinfo.info
|
||||
kwargs['shuffle'] = shuffle
|
||||
kwargs['verbose'] = verbose
|
||||
kwargs['headless'] = headless
|
||||
kwargs['sequential'] = True
|
||||
kwargs['testingModulesDir'] = os.path.join(objdir, '_tests', 'modules')
|
||||
kwargs['utility_path'] = self.utility_path
|
||||
|
@ -1395,6 +1416,38 @@ add_test({
|
|||
self.assertInLog(TEST_PASS_STRING)
|
||||
self.assertNotInLog(TEST_FAIL_STRING)
|
||||
|
||||
def testNotHeadlessByDefault(self):
|
||||
"""
|
||||
Check that the default is not headless.
|
||||
"""
|
||||
self.writeFile("test_notHeadlessByDefault.js", HEADLESS_FALSE)
|
||||
self.writeManifest(["test_notHeadlessByDefault.js"])
|
||||
self.assertTestResult(True)
|
||||
|
||||
def testHeadlessWhenHeadlessExplicit(self):
|
||||
"""
|
||||
Check that explicitly requesting headless works when the manifest doesn't override.
|
||||
"""
|
||||
self.writeFile("test_headlessWhenExplicit.js", HEADLESS_TRUE)
|
||||
self.writeManifest(["test_headlessWhenExplicit.js"])
|
||||
self.assertTestResult(True, headless=True)
|
||||
|
||||
def testHeadlessWhenHeadlessTrueInManifest(self):
|
||||
"""
|
||||
Check that enabling headless in the manifest alone works.
|
||||
"""
|
||||
self.writeFile("test_headlessWhenTrueInManifest.js", HEADLESS_TRUE)
|
||||
self.writeManifest([("test_headlessWhenTrueInManifest.js", "headless = true")])
|
||||
self.assertTestResult(True)
|
||||
|
||||
def testNotHeadlessWhenHeadlessFalseInManifest(self):
|
||||
"""
|
||||
Check that the manifest entry overrides the explicit default.
|
||||
"""
|
||||
self.writeFile("test_notHeadlessWhenFalseInManifest.js", HEADLESS_FALSE)
|
||||
self.writeManifest([("test_notHeadlessWhenFalseInManifest.js", "headless = false")])
|
||||
self.assertTestResult(True, headless=True)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
mozunit.main()
|
||||
|
|
|
@ -144,6 +144,11 @@ def add_common_arguments(parser):
|
|||
action="store_true", default=False,
|
||||
dest="enable_webrender",
|
||||
help="Enable the WebRender compositor in Gecko.")
|
||||
parser.add_argument("--headless",
|
||||
action="store_true", default=False,
|
||||
dest="headless",
|
||||
help="Enable headless mode by default for tests which don't specify "
|
||||
"whether to use headless mode")
|
||||
|
||||
|
||||
def add_remote_arguments(parser):
|
||||
|
|
Загрузка…
Ссылка в новой задаче