From a2dc1440c5ad9b9c259525eddf7658db2fd1e204 Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Fri, 20 Dec 2019 22:17:13 +0000 Subject: [PATCH] Bug 1603844 - [mochitest] Fix a failure in the 'test_get_active_tests.py' selftest, r=gbrown Differential Revision: https://phabricator.services.mozilla.com/D58051 --HG-- extra : moz-landing-system : lando --- .../tests/python/test_get_active_tests.py | 74 ++++++++++++------- 1 file changed, 48 insertions(+), 26 deletions(-) diff --git a/testing/mochitest/tests/python/test_get_active_tests.py b/testing/mochitest/tests/python/test_get_active_tests.py index affa51c4793a..89c20c0f3c18 100644 --- a/testing/mochitest/tests/python/test_get_active_tests.py +++ b/testing/mochitest/tests/python/test_get_active_tests.py @@ -46,9 +46,9 @@ def create_manifest(tmpdir, build_obj): def inner(string, name='manifest.ini'): manifest = tmpdir.join(name) - manifest.write(string) + manifest.write(string, ensure=True) path = unicode(manifest) - return TestManifest(manifests=(path,), strict=False) + return TestManifest(manifests=(path,), strict=False, rootdir=tmpdir.strpath) return inner @@ -79,30 +79,6 @@ def test_prefs_validation(get_active_tests, create_manifest): assert len(prefs) == 1 assert prefs.pop() == "\nfoo=bar\nbrowser.dom.foo=baz" - # Test prefs set by an ancestor manifest. - manifest = create_manifest(dedent(""" - [DEFAULT] - prefs = - browser.dom.foo=fleem - flower=rose - - [include:manifest.ini] - [test_foo.html] - """), name='ancestor-manifest.ini') - options['manifestFile'] = manifest - md, tests = get_active_tests(**options) - assert len(tests) == 3 - - assert 'ancestor-manifest.ini' in md.prefs_by_manifest - prefs = md.prefs_by_manifest['ancestor-manifest.ini'] - assert len(prefs) == 1 - assert prefs.pop() == '\nbrowser.dom.foo=fleem\nflower=rose' - - assert 'ancestor-manifest.ini:manifest.ini' in md.prefs_by_manifest - prefs = md.prefs_by_manifest['ancestor-manifest.ini:manifest.ini'] - assert len(prefs) == 1 - assert prefs.pop() == '\nbrowser.dom.foo=fleem\nflower=rose \nfoo=bar\nbrowser.dom.foo=baz' - # Test prefs set with runByManifest disabled. options['runByManifest'] = False with pytest.raises(SystemExit): @@ -119,5 +95,51 @@ def test_prefs_validation(get_active_tests, create_manifest): get_active_tests(**options) +def test_prefs_validation_with_ancestor_manifest(get_active_tests, create_manifest): + # Test prefs set by an ancestor manifest. + create_manifest(dedent(""" + [DEFAULT] + prefs= + foo=bar + browser.dom.foo=baz + + [files/test_pass.html] + [files/test_fail.html] + """), name='subdir/manifest.ini') + + manifest = create_manifest(dedent(""" + [DEFAULT] + prefs = + browser.dom.foo=fleem + flower=rose + + [include:manifest.ini] + [test_foo.html] + """), name='subdir/ancestor-manifest.ini') + + options = { + 'runByManifest': True, + 'manifestFile': manifest, + } + + md, tests = get_active_tests(**options) + assert len(tests) == 3 + + key = os.path.join('subdir', 'ancestor-manifest.ini') + assert key in md.prefs_by_manifest + prefs = md.prefs_by_manifest[key] + assert len(prefs) == 1 + assert prefs.pop() == '\nbrowser.dom.foo=fleem\nflower=rose' + + key = '{}:{}'.format( + os.path.join('subdir', 'ancestor-manifest.ini'), + os.path.join('subdir', 'manifest.ini') + ) + assert key in md.prefs_by_manifest + prefs = md.prefs_by_manifest[key] + assert len(prefs) == 1 + assert prefs.pop() == '\nbrowser.dom.foo=fleem\nflower=rose \nfoo=bar\nbrowser.dom.foo=baz' + + if __name__ == '__main__': mozunit.main()