summaryrefslogtreecommitdiff
path: root/morphlib/cachekeycomputer_tests.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2012-04-12 14:54:22 +0100
committerRichard Maw <richard.maw@codethink.co.uk>2012-04-12 17:36:26 +0100
commit6fad174aa361b1b921fa9dae801239f2fa5fa397 (patch)
treea5b2c69eeb20a783dd0357f48dbea2e8df10e92e /morphlib/cachekeycomputer_tests.py
parent8902a85ee612e98601daea8cca1e46c49511d106 (diff)
downloadmorph-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.
Diffstat (limited to 'morphlib/cachekeycomputer_tests.py')
-rw-r--r--morphlib/cachekeycomputer_tests.py32
1 files changed, 17 insertions, 15 deletions
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"