Bug 1366729 - Skip manifest entries that are packaged twice. r?gps draft
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 23 May 2017 08:00:15 +0900
changeset 582695 795b9715ed9d2d28702b60922dc641fcd452678b
parent 582694 b9a36219ebfe255be65c569982b226f8fd9af219
child 583379 63e5810f8bee7857904b7a4818ca18463b4cbb57
push id60143
push userbmo:mh+mozilla@glandium.org
push dateMon, 22 May 2017 23:01:28 +0000
reviewersgps
bugs1366729
milestone55.0a1
Bug 1366729 - Skip manifest entries that are packaged twice. r?gps
python/mozbuild/mozpack/packager/formats.py
python/mozbuild/mozpack/test/test_packager_formats.py
--- 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()