bug 1255485 - add some tests for building programs in dist/bin. r=nalexander

MozReview-Commit-ID: 94uOsInnWmT
This commit is contained in:
Ted Mielczarek 2018-01-17 11:19:19 -05:00
parent 39f62680ca
commit e2218ff804
13 changed files with 104 additions and 0 deletions

View File

@ -197,6 +197,14 @@ CONFIGS = defaultdict(lambda: {
'BIN_SUFFIX': '',
},
},
'program-paths': {
'defines': {},
'non_global_defines': [],
'substs': {
'COMPILE_ENVIRONMENT': '1',
'BIN_SUFFIX': '.prog',
},
},
})

View File

@ -0,0 +1,4 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
Program('dist-bin')

View File

@ -0,0 +1,5 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
DIST_SUBDIR = 'foo'
Program('dist-subdir')

View File

@ -0,0 +1,5 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
FINAL_TARGET = 'final/target'
Program('final-target')

View File

@ -0,0 +1,13 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
@template
def Program(name):
PROGRAM = name
DIRS += [
'dist-bin',
'dist-subdir',
'final-target',
'not-installed',
]

View File

@ -0,0 +1,5 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
DIST_INSTALL = False
Program('not-installed')

View File

@ -1032,6 +1032,25 @@ class TestRecursiveMakeBackend(BackendTester):
# way to iterate the manifest.
self.assertFalse('instrumentation/./not_packaged.java' in m)
def test_program_paths(self):
"""PROGRAMs with various moz.build settings that change the destination should produce
the expected paths in backend.mk."""
env = self._consume('program-paths', RecursiveMakeBackend)
expected = [
('dist-bin', '$(DEPTH)/dist/bin/dist-bin.prog'),
('dist-subdir', '$(DEPTH)/dist/bin/foo/dist-subdir.prog'),
('final-target', '$(DEPTH)/final/target/final-target.prog'),
('not-installed', 'not-installed.prog'),
]
prefix = 'PROGRAM = '
for (subdir, expected_program) in expected:
with open(os.path.join(env.topobjdir, subdir, 'backend.mk'), 'rb') as fh:
lines = fh.readlines()
program = [line.rstrip().split(prefix, 1)[1] for line in lines
if line.startswith(prefix)][0]
self.assertEqual(program, expected_program)
if __name__ == '__main__':
main()

View File

@ -0,0 +1,4 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
Program('dist-bin')

View File

@ -0,0 +1,5 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
DIST_SUBDIR = 'foo'
Program('dist-subdir')

View File

@ -0,0 +1,5 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
FINAL_TARGET = 'final/target'
Program('final-target')

View File

@ -0,0 +1,13 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
@template
def Program(name):
PROGRAM = name
DIRS += [
'dist-bin',
'dist-subdir',
'final-target',
'not-installed',
]

View File

@ -0,0 +1,5 @@
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
DIST_INSTALL = False
Program('not-installed')

View File

@ -663,6 +663,19 @@ class TestEmitterBasic(unittest.TestCase):
'test_program2.%s' %
reader.config.substs['OBJ_SUFFIX'])])
def test_program_paths(self):
"""Various moz.build settings that change the destination of PROGRAM should be
accurately reflected in Program.output_path."""
reader = self.reader('program-paths')
objs = self.read_topsrcdir(reader)
prog_paths = [o.output_path for o in objs if isinstance(o, Program)]
self.assertEqual(prog_paths, [
'!/dist/bin/dist-bin.prog',
'!/dist/bin/foo/dist-subdir.prog',
'!/final/target/final-target.prog',
'!not-installed.prog',
])
def test_test_manifest_missing_manifest(self):
"""A missing manifest file should result in an error."""
reader = self.reader('test-manifest-missing-manifest')