summaryrefslogtreecommitdiff
path: root/morphlib/cachekeycomputer_tests.py
diff options
context:
space:
mode:
authorLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-05-09 17:45:57 +0100
committerLars Wirzenius <lars.wirzenius@codethink.co.uk>2012-05-09 17:45:57 +0100
commit5b8c9e5ce0ffd6dec032c3637069b9dbc91e718f (patch)
tree7c9297a3548c48183a8e97e62dc4ac49ac33463c /morphlib/cachekeycomputer_tests.py
parenta1305ad1e8f0496b42a6037ed114523d963d9698 (diff)
downloadmorph-5b8c9e5ce0ffd6dec032c3637069b9dbc91e718f.tar.gz
Change cache keys for strata, systems to use sha of morphology, instead of commit
This avoids a problem where we make a change to one system morphology in the "morphs" repository, and then we have to rebuild all system and stratum artifacts, because their commit sha1 also changed. With this change, we don't care about the commit sha1 for systems and strata, just the contents of the morphologies.
Diffstat (limited to 'morphlib/cachekeycomputer_tests.py')
-rw-r--r--morphlib/cachekeycomputer_tests.py18
1 files changed, 18 insertions, 0 deletions
diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py
index 51616a12..7fc47370 100644
--- a/morphlib/cachekeycomputer_tests.py
+++ b/morphlib/cachekeycomputer_tests.py
@@ -148,3 +148,21 @@ class CacheKeyComputerTests(unittest.TestCase):
ckc = morphlib.cachekeycomputer.CacheKeyComputer(build_env)
self.assertNotEqual(oldsha, ckc.compute_key(artifact))
+
+ def test_same_morphology_text_but_changed_sha1_gives_same_cache_key(self):
+ old_artifact = self._find_artifact('system')
+ morphology = old_artifact.source.morphology
+ new_source = morphlib.source.Source('repo', 'original/ref', 'newsha',
+ morphology,
+ old_artifact.source.filename)
+ self.source_pool.add(new_source)
+ artifacts = self.artifact_resolver.resolve_artifacts(self.source_pool)
+ for new_artifact in artifacts:
+ if new_artifact.source == new_source:
+ break
+ else:
+ self.assertTrue(False)
+
+ old_sha = self.ckc.compute_key(old_artifact)
+ new_sha = self.ckc.compute_key(new_artifact)
+ self.assertEqual(old_sha, new_sha)