diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2013-02-22 19:07:13 +0000 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2013-03-13 15:20:02 +0000 |
commit | ece7f823de6bd61a0676edf71a9525697848824e (patch) | |
tree | 98c408d5960915f0cb5b98a941e2dc6508047f8b /morphlib/buildenvironment_tests.py | |
parent | 6a61dd9cc1fe8a3ccd2128fb628ed929fd496ad0 (diff) | |
download | morph-ece7f823de6bd61a0676edf71a9525697848824e.tar.gz |
Refactor build process
Reorganise the build_artifact() and build_artifacts() functions to
allow more complex work when setting up chunk builds in
build_artifact().
The staging area now holds the BuildEnvironment object (the
environment variables that should be set during build). This makes sense
because all build commands should be run inside the staging area and
therefore through the StagingArea object.
The BuildEnvironment object is now considered immutable after it is
created. The environment is used in cache key computation when
computing what artifacts are required; if it changes after that point
we risk either computing different artifact keys for the same artifact
or missing data in the cache key that should be included in the hash.
Better to force changes into a separate 'extra_env' variable.
Diffstat (limited to 'morphlib/buildenvironment_tests.py')
-rw-r--r-- | morphlib/buildenvironment_tests.py | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/morphlib/buildenvironment_tests.py b/morphlib/buildenvironment_tests.py index a55cd5ac..2af3f605 100644 --- a/morphlib/buildenvironment_tests.py +++ b/morphlib/buildenvironment_tests.py @@ -14,6 +14,7 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +import copy import unittest import morphlib @@ -24,8 +25,6 @@ class BuildEnvironmentTests(unittest.TestCase): def setUp(self): self.settings = { - 'toolchain-target': '%s-baserock-linux-gnu' % morphlib.util.arch(), - 'target-cflags': '', 'prefix': '/usr', 'no-ccache': True, 'no-distcc': True @@ -44,13 +43,6 @@ class BuildEnvironmentTests(unittest.TestCase): arch='noarch') self.assertEqual(buildenv.arch, 'noarch') - def test_sets_default_path(self): - olddefaultpath = buildenvironment.BuildEnvironment._default_path - buildenvironment.BuildEnvironment._default_path = self.default_path - buildenv = buildenvironment.BuildEnvironment(self.settings) - buildenvironment.BuildEnvironment._default_path = olddefaultpath - self.assertTrue(self.default_path in buildenv.env['PATH']) - def test_copies_whitelist_vars(self): env = self.fake_env safe = { @@ -62,15 +54,15 @@ class BuildEnvironmentTests(unittest.TestCase): 'FAKEROOT_FD_BASE': '-1', } env.update(safe) - old_osenv = buildenvironment.BuildEnvironment._osenv buildenvironment.BuildEnvironment._osenv = env - buildenv = buildenvironment.BuildEnvironment(self.settings) - buildenvironment.BuildEnvironment._osenv = old_osenv + buildenv = buildenvironment.BuildEnvironment(self.settings) self.assertEqual(sorted(safe.items()), sorted([(k, buildenv.env[k]) for k in safe.keys()])) + buildenvironment.BuildEnvironment._osenv = old_osenv + def test_user_spellings_equal(self): buildenv = buildenvironment.BuildEnvironment(self.settings) self.assertTrue(buildenv.env['USER'] == buildenv.env['USERNAME'] == @@ -88,16 +80,13 @@ class BuildEnvironmentTests(unittest.TestCase): def test_environment_settings_set(self): buildenv = buildenvironment.BuildEnvironment(self.settings) - self.assertEqual(buildenv.env['TOOLCHAIN_TARGET'], - self.settings['toolchain-target']) - self.assertEqual(buildenv.env['CFLAGS'], - self.settings['target-cflags']) - self.assertEqual(buildenv.env['PREFIX'], - self.settings['prefix']) + #self.assertEqual(buildenv.env['TOOLCHAIN_TARGET'], + # self.settings['toolchain-target']) def test_ccache_vars_set(self): - self.settings['no-ccache'] = False - self.settings['no-distcc'] = False - buildenv = buildenvironment.BuildEnvironment(self.settings) - self.assertTrue(buildenv._ccache_path in buildenv.env['PATH']) + new_settings = copy.copy(self.settings) + new_settings['no-ccache'] = False + new_settings['no-distcc'] = False + buildenv = buildenvironment.BuildEnvironment(new_settings) + self.assertTrue(buildenv._ccache_path in buildenv.extra_path) self.assertEqual(buildenv.env['CCACHE_PREFIX'], 'distcc') |