Bug 1366729 - Skip manifest entries that are packaged twice. r?gps
--- a/python/mozbuild/mozpack/packager/formats.py
+++ b/python/mozbuild/mozpack/packager/formats.py
@@ -167,16 +167,19 @@ class FlatSubFormatter(object):
entries = data.setdefault(entry.type, {}) \
.setdefault(entry.id, [])
else:
entries = data.setdefault(entry.type, [])
for e in entries:
# Ideally, we'd actually check whether entry.flags are more
# specific than e.flags, but in practice the following test
# is enough for now.
+ if entry == e:
+ errors.warn('"%s" is duplicated. Skipping.' % entry)
+ return
if not entry.flags or e.flags and entry.flags == e.flags:
errors.fatal('"%s" overrides "%s"' % (entry, e))
entries.append(entry)
self.copier[path].add(entry)
def add_interfaces(self, path, content):
# Interfaces in the same directory are all linked together in an
--- a/python/mozbuild/mozpack/test/test_packager_formats.py
+++ b/python/mozbuild/mozpack/test/test_packager_formats.py
@@ -29,16 +29,17 @@ from mozpack.errors import (
from mozpack.test.test_files import (
MockDest,
foo_xpt,
foo2_xpt,
bar_xpt,
read_interfaces,
)
import mozpack.path as mozpath
+from test_errors import TestErrors
CONTENTS = {
'bases': {
# base_path: is_addon?
'': False,
'app': False,
'addon0': 'unpacked',
@@ -301,17 +302,17 @@ def get_contents(registry, read_all=Fals
result[k] = get_contents(v)
elif isinstance(v, ManifestFile) or read_all:
result[k] = v.open().read().splitlines()
else:
result[k] = v
return result
-class TestFormatters(unittest.TestCase):
+class TestFormatters(TestErrors, unittest.TestCase):
maxDiff = None
def test_bases(self):
formatter = FlatFormatter(FileRegistry())
formatter.add_base('')
formatter.add_base('browser')
formatter.add_base('addon0', addon=True)
self.assertEqual(formatter._get_base('platform.ini'),
@@ -493,11 +494,18 @@ class TestFormatters(unittest.TestCase):
with self.assertRaises(ErrorMessage) as e:
f.add_manifest(ManifestLocale('chrome', 'foo', 'en-US',
'foo/locale/en-US/foo'))
self.assertEqual(e.exception.message,
'Error: "locale foo en-US foo/locale/en-US/foo" overrides '
'"locale foo en-US foo/locale/en-US/"')
+ # Duplicating existing manifest entries is not an error.
+ f.add_manifest(ManifestContent('chrome', 'foo', 'foo/unix'))
+
+ self.assertEqual(self.get_output(), [
+ 'Warning: "content foo foo/unix" is duplicated. Skipping.',
+ ])
+
if __name__ == '__main__':
mozunit.main()