Bug 939080 - Allow support-files in manifests to exist in parent paths; r=ted

--HG--
extra : rebase_source : bfc18cc5daf4a3e08b21c45203cb9a9c53e868a9
This commit is contained in:
Gregory Szorc 2013-11-18 11:55:33 -08:00
parent 116092759a
commit 583c981e1a
16 changed files with 90 additions and 44 deletions

View File

@ -176,9 +176,6 @@ Files referenced by manifests are automatically installed into the object
directory into paths defined in
:py:func:`mozbuild.frontend.emitter.TreeMetadataEmitter._process_test_manifest`.
Referenced files in the manifest not in the same directory tree as the manifest
file are **not** installed.
.. _reftest_manifests:
Reftest Manifests

View File

@ -1017,12 +1017,14 @@ class RecursiveMakeBackend(CommonBackend):
self.backend_input_files.add(os.path.join(obj.topsrcdir,
obj.manifest_relpath))
# Duplicate manifests may define the same file. That's OK.
for source, dest in obj.installs.items():
# Don't allow files to be defined multiple times unless it is allowed.
# We currently allow duplicates for non-test files or test files if
# the manifest is listed as a duplicate.
for source, (dest, is_test) in obj.installs.items():
try:
self._install_manifests['tests'].add_symlink(source, dest)
except ValueError:
if not obj.dupe_manifest:
if not obj.dupe_manifest and is_test:
raise
for dest in obj.external_installs:

View File

@ -357,7 +357,9 @@ class TestManifest(SandboxDerived):
'flavor',
# Maps source filename to destination filename. The destination
# path is relative from the tests root directory.
# path is relative from the tests root directory. Values are 2-tuples
# of (destpath, is_test_file) where the 2nd item is True if this
# item represents a test file (versus a support file).
'installs',
# Where all files for this manifest flavor are installed in the unified

View File

@ -415,7 +415,7 @@ class TreeMetadataEmitter(LoggingMixin):
obj.tests.append(test)
obj.installs[mozpath.normpath(test['path'])] = \
mozpath.join(out_dir, test['relpath'])
(mozpath.join(out_dir, test['relpath']), True)
for thing, seen in extras:
value = test.get(thing, '')
@ -439,21 +439,18 @@ class TreeMetadataEmitter(LoggingMixin):
for f in paths:
full = mozpath.normpath(mozpath.join(manifest_dir, f))
obj.installs[full] = mozpath.join(out_dir, f)
obj.installs[full] = \
(mozpath.join(out_dir, f), False)
else:
full = mozpath.normpath(mozpath.join(manifest_dir,
pattern))
# Only install paths in our directory. This
# rule is somewhat arbitrary and could be lifted.
if not full.startswith(manifest_dir):
continue
obj.installs[full] = mozpath.join(out_dir, pattern)
obj.installs[full] = (mozpath.normpath(
mozpath.join(out_dir, pattern)), False)
# We also copy the manifest into the output directory.
out_path = mozpath.join(out_dir, os.path.basename(manifest_path))
obj.installs[path] = out_path
obj.installs[path] = (out_path, False)
# Some manifests reference files that are auto generated as
# part of the build or shouldn't be installed for some

View File

@ -98,6 +98,11 @@ CONFIGS = {
'non_global_defines': [],
'substs': [],
},
'test-manifests-duplicate-support-files': {
'defines': [],
'non_global_defines': [],
'substs': [],
},
}

View File

@ -0,0 +1,4 @@
[DEFAULT]
support-files = support-file.txt
[test_foo.js]

View File

@ -0,0 +1,4 @@
[DEFAULT]
support-files = support-file.txt
[test_bar.js]

View File

@ -0,0 +1,7 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
MOCHITEST_MANIFESTS += [
'mochitest1.ini',
'mochitest2.ini',
]

View File

@ -527,7 +527,6 @@ class TestRecursiveMakeBackend(BackendTester):
env = self._consume('final_target', RecursiveMakeBackend)
final_target_rule = "FINAL_TARGET = $(if $(XPI_NAME),$(DIST)/xpi-stage/$(XPI_NAME),$(DIST)/bin)$(DIST_SUBDIR:%=/%)"
print([x for x in os.walk(env.topobjdir)])
expected = dict()
expected[env.topobjdir] = []
expected[os.path.join(env.topobjdir, 'both')] = [
@ -554,6 +553,15 @@ class TestRecursiveMakeBackend(BackendTester):
str.startswith('DIST_SUBDIR')]
self.assertEqual(found, expected_rules)
def test_test_manifests_duplicate_support_files(self):
"""Ensure duplicate support-files in test manifests work."""
env = self._consume('test-manifests-duplicate-support-files',
RecursiveMakeBackend)
p = os.path.join(env.topobjdir, '_build_manifests', 'install', 'tests')
m = InstallManifest(p)
self.assertIn('testing/mochitest/tests/support-file.txt', m)
if __name__ == '__main__':
main()

View File

@ -0,0 +1,4 @@
[DEFAULT]
support-files = ../support-file.txt
[test_foo.js]

View File

@ -0,0 +1,4 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
MOCHITEST_MANIFESTS += ['child/mochitest.ini']

View File

@ -249,34 +249,34 @@ class TestEmitterBasic(unittest.TestCase):
'a11y.ini': {
'flavor': 'a11y',
'installs': {
'a11y.ini',
'test_a11y.js',
'a11y.ini': False,
'test_a11y.js': True,
# From ** wildcard.
'a11y-support/foo',
'a11y-support/dir1/bar',
'a11y-support/foo': False,
'a11y-support/dir1/bar': False,
},
},
'browser.ini': {
'flavor': 'browser-chrome',
'installs': {
'browser.ini',
'test_browser.js',
'support1',
'support2',
'browser.ini': False,
'test_browser.js': True,
'support1': False,
'support2': False,
},
},
'metro.ini': {
'flavor': 'metro-chrome',
'installs': {
'metro.ini',
'test_metro.js',
'metro.ini': False,
'test_metro.js': True,
},
},
'mochitest.ini': {
'flavor': 'mochitest',
'installs': {
'mochitest.ini',
'test_mochitest.js',
'mochitest.ini': False,
'test_mochitest.js': True,
},
'external': {
'external1',
@ -286,20 +286,20 @@ class TestEmitterBasic(unittest.TestCase):
'chrome.ini': {
'flavor': 'chrome',
'installs': {
'chrome.ini',
'test_chrome.js',
'chrome.ini': False,
'test_chrome.js': True,
},
},
'xpcshell.ini': {
'flavor': 'xpcshell',
'dupe': True,
'installs': {
'xpcshell.ini',
'test_xpcshell.js',
'head1',
'head2',
'tail1',
'tail2',
'xpcshell.ini': False,
'test_xpcshell.js': True,
'head1': False,
'head2': False,
'tail1': False,
'tail2': False,
},
},
}
@ -318,9 +318,10 @@ class TestEmitterBasic(unittest.TestCase):
self.assertEqual(len(o.installs), len(m['installs']))
for path in o.installs.keys():
self.assertTrue(path.startswith(o.directory))
path = path[len(o.directory)+1:]
relpath = path[len(o.directory)+1:]
self.assertIn(path, m['installs'])
self.assertIn(relpath, m['installs'])
self.assertEqual(o.installs[path][1], m['installs'][relpath])
def test_test_manifest_unmatched_generated(self):
reader = self.reader('test-manifest-unmatched-generated')
@ -346,6 +347,22 @@ class TestEmitterBasic(unittest.TestCase):
basenames = set(os.path.basename(k) for k in o.installs.keys())
self.assertEqual(basenames, {'mochitest.ini', 'test_active.html'})
def test_test_manifest_parent_support_files_dir(self):
"""support-files referencing a file in a parent directory works."""
reader = self.reader('test-manifest-parent-support-files-dir')
objs = [o for o in self.read_topsrcdir(reader)
if isinstance(o, TestManifest)]
self.assertEqual(len(objs), 1)
o = objs[0]
expected = os.path.join(o.srcdir, 'support-file.txt')
self.assertIn(expected, o.installs)
self.assertEqual(o.installs[expected],
('testing/mochitest/tests/support-file.txt', False))
def test_ipdl_sources(self):
reader = self.reader('ipdl_sources')
objs = self.read_topsrcdir(reader)

View File

@ -2,11 +2,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
MOCHITEST_CHROME_FILES := \
../widgets/popup_shared.js \
../widgets/tree_shared.js \
$(SHULL)
# test_panel_focus.xul won't work if the Full Keyboard Access preference is set to
# textboxes and lists only, so skip this test on Mac
ifneq (cocoa,$(MOZ_WIDGET_TOOLKIT))