Bug 1068923 - Provide the including manifest name to uniquely identify tests in case of a dupe manifest. r=ahal

The path of the including manifest is included in test objects whenever possible to aide identification of tests in cases the same test file is included by multiple manifests.
This commit is contained in:
Chris Manchester 2014-10-22 16:04:51 -04:00
parent 4f25400d85
commit 7d5a7c9529
2 changed files with 14 additions and 3 deletions

View File

@ -420,7 +420,7 @@ class ManifestParser(object):
### methods for reading manifests
def _read(self, root, filename, defaults, defaults_only=False):
def _read(self, root, filename, defaults, defaults_only=False, parentmanifest=None):
"""
Internal recursive method for reading and parsing manifests.
Stores all found tests in self.tests
@ -492,7 +492,7 @@ class ManifestParser(object):
include_file = read_file('include:')
if include_file:
include_defaults = data.copy()
self._read(root, include_file, include_defaults)
self._read(root, include_file, include_defaults, parentmanifest=filename)
continue
# otherwise an item
@ -534,6 +534,13 @@ class ManifestParser(object):
test['path'] = path
test['relpath'] = _relpath
if parentmanifest is not None:
# If a test was included by a parent manifest we may need to
# indicate that in the test object for the sake of identifying
# a test, particularly in the case a test file is included by
# multiple manifests.
test['ancestor-manifest'] = parentmanifest
# append the item
self.tests.append(test)
@ -765,7 +772,7 @@ class ManifestParser(object):
print >> fp, '[%s]' % path
# reserved keywords:
reserved = ['path', 'name', 'here', 'manifest', 'relpath']
reserved = ['path', 'name', 'here', 'manifest', 'relpath', 'ancestor-manifest']
for key in sorted(test.keys()):
if key in reserved:
continue

View File

@ -60,6 +60,10 @@ class TestManifestParser(unittest.TestCase):
self.assertEqual([(test['name'], os.path.basename(test['manifest'])) for test in parser.tests],
[('crash-handling', 'bar.ini'), ('fleem', 'include-example.ini'), ('flowers', 'foo.ini')])
# The including manifest is always reported as a part of the generated test object.
self.assertTrue(all([t['ancestor-manifest'] == include_example
for t in parser.tests if t['name'] != 'fleem']))
# The manifests should be there too:
self.assertEqual(len(parser.manifests()), 3)