forked from sailfishos/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1229233 - Add a (incomplete) end-to-end build test. r=gps
We have many unit tests in the tree for some small parts of the build system pipeline, but we don't have anything that resembles an end to end test, and we kind of rely on the resulting Firefox not being broken by our changes. With the Faster make backend growing, I want to ensure it produces the same thing as the recursive make backend, at least for the parts it supports. This adds some kind of test that allows to check that.
- Loading branch information
Showing
21 changed files
with
324 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
python/mozbuild/mozbuild/test/backend/data/build/app/moz.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
DIST_SUBDIR = 'app' | ||
|
||
EXTRA_JS_MODULES += [ | ||
'../foo.jsm', | ||
] | ||
|
||
EXTRA_JS_MODULES.child += [ | ||
'../bar.jsm', | ||
] | ||
|
||
EXTRA_PP_JS_MODULES += [ | ||
'../baz.jsm', | ||
] | ||
|
||
EXTRA_PP_JS_MODULES.child2 += [ | ||
'../qux.jsm', | ||
] | ||
|
||
FINAL_TARGET_FILES += [ | ||
'../foo.ini', | ||
] | ||
|
||
FINAL_TARGET_FILES.child += [ | ||
'../bar.ini', | ||
] | ||
|
||
FINAL_TARGET_PP_FILES += [ | ||
'../baz.ini', | ||
] | ||
|
||
FINAL_TARGET_PP_FILES.child2 += [ | ||
'../qux.ini', | ||
] | ||
|
||
EXTRA_COMPONENTS += [ | ||
'../components.manifest', | ||
'../foo.js', | ||
] | ||
|
||
EXTRA_PP_COMPONENTS += [ | ||
'../bar.js', | ||
] | ||
|
||
JS_PREFERENCE_FILES += [ | ||
'../prefs.js', | ||
] | ||
|
||
DEFINES['FOO'] = 'bar' | ||
DEFINES['BAR'] = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bar.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#filter substitution | ||
bar.js: FOO is @FOO@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bar.jsm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#filter substitution | ||
baz.ini: FOO is @FOO@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#filter substitution | ||
baz.jsm: FOO is @FOO@ |
2 changes: 2 additions & 0 deletions
2
python/mozbuild/mozbuild/test/backend/data/build/components.manifest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
component {foo} foo.js | ||
component {bar} bar.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foo.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foo.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
foo.jsm |
63 changes: 63 additions & 0 deletions
63
python/mozbuild/mozbuild/test/backend/data/build/moz.build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
CONFIGURE_SUBST_FILES += [ | ||
'/config/autoconf.mk', | ||
'/config/emptyvars.mk', | ||
] | ||
|
||
EXTRA_JS_MODULES += [ | ||
'foo.jsm', | ||
] | ||
|
||
EXTRA_JS_MODULES.child += [ | ||
'bar.jsm', | ||
] | ||
|
||
EXTRA_PP_JS_MODULES += [ | ||
'baz.jsm', | ||
] | ||
|
||
EXTRA_PP_JS_MODULES.child2 += [ | ||
'qux.jsm', | ||
] | ||
|
||
FINAL_TARGET_FILES += [ | ||
'foo.ini', | ||
] | ||
|
||
FINAL_TARGET_FILES.child += [ | ||
'bar.ini', | ||
] | ||
|
||
FINAL_TARGET_PP_FILES += [ | ||
'baz.ini', | ||
] | ||
|
||
FINAL_TARGET_PP_FILES.child2 += [ | ||
'qux.ini', | ||
] | ||
|
||
EXTRA_COMPONENTS += [ | ||
'components.manifest', | ||
'foo.js', | ||
] | ||
|
||
EXTRA_PP_COMPONENTS += [ | ||
'bar.js', | ||
] | ||
|
||
JS_PREFERENCE_FILES += [ | ||
'prefs.js', | ||
] | ||
|
||
RESOURCE_FILES += [ | ||
'resource', | ||
] | ||
|
||
RESOURCE_FILES.child += [ | ||
'resource2', | ||
] | ||
|
||
DEFINES['FOO'] = 'foo' | ||
|
||
DIRS += [ | ||
'app', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
prefs.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#ifdef BAR | ||
qux.ini: BAR is defined | ||
#else | ||
qux.ini: BAR is not defined | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#ifdef BAR | ||
qux.jsm: BAR is defined | ||
#else | ||
qux.jsm: BAR is not defined | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
resource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
resource2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
from __future__ import unicode_literals, print_function | ||
|
||
import buildconfig | ||
import os | ||
import shutil | ||
import sys | ||
import unittest | ||
import mozpack.path as mozpath | ||
from contextlib import contextmanager | ||
from mozunit import main | ||
from mozbuild.backend.configenvironment import ConfigEnvironment | ||
from mozbuild.backend.recursivemake import RecursiveMakeBackend | ||
from mozbuild.backend.fastermake import FasterMakeBackend | ||
from mozbuild.base import MozbuildObject | ||
from mozbuild.frontend.emitter import TreeMetadataEmitter | ||
from mozbuild.frontend.reader import BuildReader | ||
from mozbuild.util import ensureParentDir | ||
from mozpack.files import FileFinder | ||
from tempfile import mkdtemp | ||
|
||
|
||
BASE_SUBSTS = [ | ||
('PYTHON', sys.executable), | ||
] | ||
|
||
|
||
class TestBuild(unittest.TestCase): | ||
@contextmanager | ||
def do_test_backend(self, *backends, **kwargs): | ||
topobjdir = mkdtemp() | ||
try: | ||
config = ConfigEnvironment(buildconfig.topsrcdir, topobjdir, | ||
**kwargs) | ||
reader = BuildReader(config) | ||
emitter = TreeMetadataEmitter(config) | ||
moz_build = mozpath.join(config.topsrcdir, 'test.mozbuild') | ||
definitions = list(emitter.emit( | ||
reader.read_mozbuild(moz_build, config))) | ||
for backend in backends: | ||
backend(config).consume(definitions) | ||
|
||
yield config | ||
except: | ||
raise | ||
finally: | ||
if not os.environ.get('MOZ_NO_CLEANUP'): | ||
shutil.rmtree(topobjdir) | ||
|
||
@contextmanager | ||
def line_handler(self): | ||
lines = [] | ||
|
||
def handle_make_line(line): | ||
lines.append(line) | ||
|
||
try: | ||
yield handle_make_line | ||
except: | ||
print('\n'.join(lines)) | ||
raise | ||
|
||
if os.environ.get('MOZ_VERBOSE_MAKE'): | ||
print('\n'.join(lines)) | ||
|
||
def test_recursive_make(self): | ||
substs = list(BASE_SUBSTS) | ||
with self.do_test_backend(RecursiveMakeBackend, | ||
substs=substs) as config: | ||
build = MozbuildObject(config.topsrcdir, None, None, | ||
config.topobjdir) | ||
overrides = [ | ||
'install_manifest_depends=', | ||
'TEST_MOZBUILD=1', | ||
] | ||
with self.line_handler() as handle_make_line: | ||
build._run_make(directory=config.topobjdir, target=overrides, | ||
silent=False, line_handler=handle_make_line) | ||
|
||
self.validate(config) | ||
|
||
def test_faster_make(self): | ||
substs = list(BASE_SUBSTS) + [ | ||
('MOZ_BUILD_APP', 'dummy_app'), | ||
('MOZ_WIDGET_TOOLKIT', 'dummy_widget'), | ||
] | ||
with self.do_test_backend(RecursiveMakeBackend, FasterMakeBackend, | ||
substs=substs) as config: | ||
buildid = mozpath.join(config.topobjdir, 'config', 'buildid') | ||
ensureParentDir(buildid) | ||
with open(buildid, 'w') as fh: | ||
fh.write('20100101012345\n') | ||
|
||
build = MozbuildObject(config.topsrcdir, None, None, | ||
config.topobjdir) | ||
overrides = [ | ||
'TEST_MOZBUILD=1', | ||
] | ||
with self.line_handler() as handle_make_line: | ||
build._run_make(directory=mozpath.join(config.topobjdir, | ||
'faster'), | ||
target=overrides, silent=False, | ||
line_handler=handle_make_line) | ||
|
||
self.validate(config) | ||
|
||
def validate(self, config): | ||
self.maxDiff = None | ||
test_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), | ||
'data', 'build') + os.sep | ||
|
||
# We want unicode instances out of the files, because having plain str | ||
# makes assertEqual diff output in case of error extra verbose because | ||
# of the difference in type. | ||
result = { | ||
p: f.open().read().decode('utf-8') | ||
for p, f in FileFinder(mozpath.join(config.topobjdir, 'dist')) | ||
} | ||
self.assertTrue(len(result)) | ||
self.assertEqual(result, { | ||
'bin/baz.ini': 'baz.ini: FOO is foo\n', | ||
'bin/child/bar.ini': 'bar.ini\n', | ||
'bin/child2/qux.ini': 'qux.ini: BAR is not defined\n', | ||
'bin/chrome.manifest': 'manifest components/components.manifest\n', | ||
'bin/components/bar.js': | ||
'//@line 2 "%sbar.js"\nbar.js: FOO is foo\n' % (test_path), | ||
'bin/components/components.manifest': | ||
'component {foo} foo.js\ncomponent {bar} bar.js\n', | ||
'bin/components/foo.js': 'foo.js\n', | ||
'bin/defaults/pref/prefs.js': 'prefs.js\n', | ||
'bin/foo.ini': 'foo.ini\n', | ||
'bin/modules/baz.jsm': | ||
'//@line 2 "%sbaz.jsm"\nbaz.jsm: FOO is foo\n' % (test_path), | ||
'bin/modules/child/bar.jsm': 'bar.jsm\n', | ||
'bin/modules/child2/qux.jsm': | ||
'//@line 4 "%squx.jsm"\nqux.jsm: BAR is not defined\n' | ||
% (test_path), | ||
'bin/modules/foo.jsm': 'foo.jsm\n', | ||
'bin/res/resource': 'resource\n', | ||
'bin/res/child/resource2': 'resource2\n', | ||
|
||
'bin/app/baz.ini': 'baz.ini: FOO is bar\n', | ||
'bin/app/child/bar.ini': 'bar.ini\n', | ||
'bin/app/child2/qux.ini': 'qux.ini: BAR is defined\n', | ||
'bin/app/chrome.manifest': 'manifest components/components.manifest\n', | ||
'bin/app/components/bar.js': | ||
'//@line 2 "%sbar.js"\nbar.js: FOO is bar\n' % (test_path), | ||
'bin/app/components/components.manifest': | ||
'component {foo} foo.js\ncomponent {bar} bar.js\n', | ||
'bin/app/components/foo.js': 'foo.js\n', | ||
'bin/app/defaults/preferences/prefs.js': 'prefs.js\n', | ||
'bin/app/foo.ini': 'foo.ini\n', | ||
'bin/app/modules/baz.jsm': | ||
'//@line 2 "%sbaz.jsm"\nbaz.jsm: FOO is bar\n' % (test_path), | ||
'bin/app/modules/child/bar.jsm': 'bar.jsm\n', | ||
'bin/app/modules/child2/qux.jsm': | ||
'//@line 2 "%squx.jsm"\nqux.jsm: BAR is defined\n' | ||
% (test_path), | ||
'bin/app/modules/foo.jsm': 'foo.jsm\n', | ||
}) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
# This file is necessary to "bootstrap" the test case for the test_build | ||
# test, because of the requirement of the top-level directory containing | ||
# config/*.mk. | ||
DIRS += [ | ||
'python/mozbuild/mozbuild/test/backend/data/build', | ||
] |