diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2012-04-12 14:54:22 +0100 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2012-04-12 17:36:26 +0100 |
commit | 6fad174aa361b1b921fa9dae801239f2fa5fa397 (patch) | |
tree | a5b2c69eeb20a783dd0357f48dbea2e8df10e92e | |
parent | 8902a85ee612e98601daea8cca1e46c49511d106 (diff) | |
download | morph-6fad174aa361b1b921fa9dae801239f2fa5fa397.tar.gz |
cachekeycomputer: prepare build environment change
CacheKeyComputer needs to know some stuff that is needed elsewhere
as well. Rather than duplicate the storage, have a BuildEnvironment
class to handle that.
-rw-r--r-- | morphlib/cachekeycomputer.py | 4 | ||||
-rw-r--r-- | morphlib/cachekeycomputer_tests.py | 32 |
2 files changed, 19 insertions, 17 deletions
diff --git a/morphlib/cachekeycomputer.py b/morphlib/cachekeycomputer.py index ade74b79..1cc377b3 100644 --- a/morphlib/cachekeycomputer.py +++ b/morphlib/cachekeycomputer.py @@ -20,9 +20,9 @@ import morphlib class CacheKeyComputer(): - def __init__(self, env): + def __init__(self, build_env): self._arch = morphlib.util.arch() - self._env = self._filterenv(env) + self._env = self._filterenv(build_env.env) self._calculated = {} def _filterenv(self, env): diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py index 5304307a..4973a948 100644 --- a/morphlib/cachekeycomputer_tests.py +++ b/morphlib/cachekeycomputer_tests.py @@ -15,22 +15,30 @@ import unittest -import json import morphlib +class DummyBuildEnvironment: + '''Fake build environment class that doesn't need + settings to pick the environment, it just gets passed + a dict representing it + ''' + def __init__(self, env, arch=None): + self.arch = morphlib.util.arch() if arch == None else arch + self.env = env class CacheKeyComputerTests(unittest.TestCase): def setUp(self): - self.env = {"USER": "foouser", - "USERNAME": "foouser", - "LOGNAME": "foouser", - "TOOLCHAIN_TARGET": "dummy-baserock-linux-gnu", - "PREFIX": "/baserock", - "BOOTSTRAP": "false", - "CFLAGS": "-O4"} - self.ckc = morphlib.cachekeycomputer.CacheKeyComputer(self.env) + self.build_env = DummyBuildEnvironment({ + "USER": "foouser", + "USERNAME": "foouser", + "LOGNAME": "foouser", + "TOOLCHAIN_TARGET": "dummy-baserock-linux-gnu", + "PREFIX": "/baserock", + "BOOTSTRAP": "false", + "CFLAGS": "-O4"}) + self.ckc = morphlib.cachekeycomputer.CacheKeyComputer(self.build_env) pool = morphlib.sourcepool.SourcePool() self.sources = {} for name, text in { @@ -82,12 +90,6 @@ class CacheKeyComputerTests(unittest.TestCase): self.assertTrue(self._valid_sha256( self.ckc.get_cache_key(self.sources['stratum.morph']))) - def test_get_cache_id_returns_dict(self): - print json.dumps(self.ckc.get_cache_id( - self.sources['stratum.morph']), - indent=2) - self.assertEqual('', ) - def test_different_env_gives_different_key(self): oldsha = self.ckc.get_cache_key(self.sources['stratum.morph']) self.ckc._env['CFLAGS'] = "-Os" |