Bug 1227892 - Add basic tests for IS_COMPONENT/NO_COMPONENTS_MANIFEST. r=gps

This commit is contained in:
Mike Hommey 2015-11-26 17:07:37 +09:00
Родитель 3900e2c115
Коммит ba507be622
10 изменённых файлов: 94 добавлений и 1 удалений

Просмотреть файл

@ -42,6 +42,14 @@ CONFIGS = defaultdict(lambda: {
('ANDROID_TARGET_SDK', '16'),
],
},
'binary-components': {
'defines': [],
'non_global_defines': [],
'substs': [
('LIB_PREFIX', 'lib'),
('LIB_SUFFIX', 'a'),
],
},
'stub0': {
'defines': [
('MOZ_TRUE_1', '1'),

Просмотреть файл

@ -0,0 +1,2 @@
Component('bar')
NO_COMPONENTS_MANIFEST = True

Просмотреть файл

@ -0,0 +1 @@
Component('foo')

Просмотреть файл

@ -0,0 +1,10 @@
@template
def Component(name):
LIBRARY_NAME = name
FORCE_SHARED_LIB = True
IS_COMPONENT = True
DIRS += [
'foo',
'bar',
]

Просмотреть файл

@ -826,6 +826,40 @@ class TestRecursiveMakeBackend(BackendTester):
# way to iterate the manifest.
self.assertFalse('instrumentation/./not_packaged.java' in m)
def test_binary_components(self):
"""Ensure binary components are correctly handled."""
env = self._consume('binary-components', RecursiveMakeBackend)
with open(mozpath.join(env.topobjdir, 'foo', 'backend.mk')) as fh:
lines = fh.readlines()[2:]
self.assertEqual(lines, [
'misc::\n',
'\t$(call py_action,buildlist,$(DEPTH)/dist/bin/chrome.manifest '
+ "'manifest components/components.manifest')\n",
'\t$(call py_action,buildlist,'
+ '$(DEPTH)/dist/bin/components/components.manifest '
+ "'binary-component foo')\n",
'LIBRARY_NAME := foo\n',
'FORCE_SHARED_LIB := 1\n',
'IMPORT_LIBRARY := foo\n',
'SHARED_LIBRARY := foo\n',
'IS_COMPONENT := 1\n',
'DSO_SONAME := foo\n',
])
with open(mozpath.join(env.topobjdir, 'bar', 'backend.mk')) as fh:
lines = fh.readlines()[2:]
self.assertEqual(lines, [
'LIBRARY_NAME := bar\n',
'FORCE_SHARED_LIB := 1\n',
'IMPORT_LIBRARY := bar\n',
'SHARED_LIBRARY := bar\n',
'IS_COMPONENT := 1\n',
'DSO_SONAME := bar\n',
])
if __name__ == '__main__':
main()

Просмотреть файл

@ -36,4 +36,8 @@ class MockConfig(object):
self.external_source_dir = None
self.lib_prefix = 'lib'
self.lib_suffix = '.so'
self.lib_suffix = '.a'
self.import_prefix = 'lib'
self.import_suffix = '.so'
self.dll_prefix = 'lib'
self.dll_suffix = '.so'

Просмотреть файл

@ -0,0 +1,2 @@
Component('bar')
NO_COMPONENTS_MANIFEST = True

Просмотреть файл

@ -0,0 +1 @@
Component('foo')

Просмотреть файл

@ -0,0 +1,10 @@
@template
def Component(name):
LIBRARY_NAME = name
FORCE_SHARED_LIB = True
IS_COMPONENT = True
DIRS += [
'foo',
'bar',
]

Просмотреть файл

@ -12,6 +12,7 @@ from mozunit import main
from mozbuild.frontend.data import (
AndroidResDirs,
BrandingFiles,
ChromeManifestEntry,
ConfigFileSubstitution,
Defines,
DistFiles,
@ -27,6 +28,7 @@ from mozbuild.frontend.data import (
LocalInclude,
Program,
Resources,
SharedLibrary,
SimpleProgram,
Sources,
StaticLibrary,
@ -41,6 +43,7 @@ from mozbuild.frontend.reader import (
BuildReaderError,
SandboxValidationError,
)
from mozpack.chrome import manifest
from mozbuild.test.common import MockConfig
@ -921,5 +924,23 @@ class TestEmitterBasic(unittest.TestCase):
]
self.assertEquals([p.full_path for p in objs[0].paths], expected)
def test_binary_components(self):
"""Test that IS_COMPONENT/NO_COMPONENTS_MANIFEST work properly."""
reader = self.reader('binary-components')
objs = self.read_topsrcdir(reader)
self.assertEqual(len(objs), 3)
self.assertIsInstance(objs[0], ChromeManifestEntry)
self.assertEqual(objs[0].path,
'dist/bin/components/components.manifest')
self.assertIsInstance(objs[0].entry, manifest.ManifestBinaryComponent)
self.assertEqual(objs[0].entry.base, 'dist/bin/components')
self.assertEqual(objs[0].entry.relpath, objs[1].lib_name)
self.assertIsInstance(objs[1], SharedLibrary)
self.assertEqual(objs[1].basename, 'foo')
self.assertIsInstance(objs[2], SharedLibrary)
self.assertEqual(objs[2].basename, 'bar')
if __name__ == '__main__':
main()