Bug 1333135 - Ensure test support binaries are tracked by install manifests in the build backend. r=mshal

Install manifests influence test packaging, allowing artifact builds to consume
generated test support files and run tests that depend on them. This commit
tracks binaries with an install target under "_tests" so they will be correctly
installed in artifact builds.

This could similarly be achieved by installing the binaries via TEST_HARNESS_FILES
rather than setting FINAL_TARGET, however, PGO builds will fail attempting to install
the files during the profile generation step, because SIMPLE_PROGRAMS are not built
for this step.

MozReview-Commit-ID: ES4bTxOoqMN

--HG--
extra : rebase_source : f41d8c47711fc15247fa336e2e9cbdedf57c2daf
This commit is contained in:
Chris Manchester 2017-01-27 14:21:29 -08:00
parent 0aa1979e85
commit d3afe369a1
8 changed files with 87 additions and 0 deletions

View File

@ -34,6 +34,8 @@ from ..frontend.data import (
AndroidExtraResDirs,
AndroidExtraPackages,
AndroidEclipseProjectData,
BaseLibrary,
BaseProgram,
ChromeManifestEntry,
ConfigFileSubstitution,
ContextDerived,
@ -55,6 +57,7 @@ from ..frontend.data import (
JARManifest,
JavaJarData,
Library,
Linkable,
LocalInclude,
ObjdirFiles,
ObjdirPreprocessedFiles,
@ -444,6 +447,9 @@ class RecursiveMakeBackend(CommonBackend):
if not isinstance(obj, Defines):
self.consume_object(obj.defines)
if isinstance(obj, Linkable):
self._process_test_support_file(obj)
if isinstance(obj, DirectoryTraversal):
self._process_directory_traversal(obj, backend_file)
elif isinstance(obj, ConfigFileSubstitution):
@ -1073,6 +1079,24 @@ class RecursiveMakeBackend(CommonBackend):
def _process_host_simple_program(self, program, backend_file):
backend_file.write('HOST_SIMPLE_PROGRAMS += %s\n' % program)
def _process_test_support_file(self, obj):
# Ensure test support programs and libraries are tracked by an
# install manifest for the benefit of the test packager.
if not obj.install_target.startswith('_tests'):
return
dest_basename = None
if isinstance(obj, BaseLibrary):
dest_basename = obj.lib_name
elif isinstance(obj, BaseProgram):
dest_basename = obj.program
if dest_basename is None:
return
self._install_manifests['_tests'].add_optional_exists(
mozpath.join(obj.install_target[len('_tests') + 1:],
dest_basename))
def _process_test_manifest(self, obj, backend_file):
# Much of the logic in this function could be moved to CommonBackend.
for source in obj.source_relpaths:

View File

@ -105,6 +105,15 @@ CONFIGS = defaultdict(lambda: {
'HOST_BIN_SUFFIX': '.exe',
},
},
'test-support-binaries-tracked': {
'defines': {},
'non_global_defines': [],
'substs': {
'COMPILE_ENVIRONMENT': '1',
'LIB_SUFFIX': 'dll',
'BIN_SUFFIX': '.exe',
},
},
'sources': {
'defines': {},
'non_global_defines': [],

View File

@ -0,0 +1,5 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
DIRS += ['test', 'src']

View File

@ -0,0 +1,10 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
@template
def Library(name):
'''Template for libraries'''
LIBRARY_NAME = name
Library('foo')

View File

@ -0,0 +1,29 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
# Any copyright is dedicated to the Public Domain.
# http://creativecommons.org/publicdomain/zero/1.0/
FINAL_TARGET = '_tests/xpcshell/tests/mozbuildtest'
@template
def Library(name):
'''Template for libraries'''
LIBRARY_NAME = name
@template
def SimplePrograms(names, ext='.cpp'):
'''Template for simple program executables.
Those have a single source with the same base name as the executable.
'''
SIMPLE_PROGRAMS += names
SOURCES += ['%s%s' % (name, ext) for name in names]
@template
def HostLibrary(name):
'''Template for build tools libraries.'''
HOST_LIBRARY_NAME = name
Library('test-library')
HostLibrary('host-test-library')
SimplePrograms(['test-one', 'test-two'])

View File

@ -606,6 +606,16 @@ class TestRecursiveMakeBackend(BackendTester):
self.assertTrue(os.path.isfile(mozpath.join(p, 'Makefile')))
def test_test_support_files_tracked(self):
env = self._consume('test-support-binaries-tracked', RecursiveMakeBackend)
m = InstallManifest(path=mozpath.join(env.topobjdir,
'_build_manifests', 'install', '_tests'))
self.assertEqual(len(m), 4)
self.assertIn('xpcshell/tests/mozbuildtest/test-library.dll', m)
self.assertIn('xpcshell/tests/mozbuildtest/test-one.exe', m)
self.assertIn('xpcshell/tests/mozbuildtest/test-two.exe', m)
self.assertIn('xpcshell/tests/mozbuildtest/host-test-library.dll', m)
def test_old_install_manifest_deleted(self):
# Simulate an install manifest from a previous backend version. Ensure
# it is deleted.