Bug 1366729 - Skip manifest entries that are packaged twice. r=gps
authorMike Hommey <mh+mozilla@glandium.org>
Tue, 23 May 2017 08:00:15 +0900
changeset 360110 249495cc2ea52fb0fa0f8f4db6894070789953bd
parent 360109 aec720895e5e79d126283c118cb4d26744c3750a
child 360111 30ef16860449d5d71796eca7bba54c95701a8144
push id43240
push usergszorc@mozilla.com
push dateTue, 23 May 2017 17:28:48 +0000
treeherderautoland@249495cc2ea5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgps
bugs1366729
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
@@ -162,16 +162,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'),
@@ -491,11 +492,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()