From fc35b41a0189eb8a43032247cbe7d3cfadf6ded1 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Wed, 10 Sep 2014 10:51:28 +0000 Subject: Remove Morphology.builds_artifacts This was used before the Artifact splitting code landed to determine which artifacts should be produced. --- morphlib/cachekeycomputer_tests.py | 6 ------ 1 file changed, 6 deletions(-) (limited to 'morphlib/cachekeycomputer_tests.py') diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py index 8558db6d..441f6123 100644 --- a/morphlib/cachekeycomputer_tests.py +++ b/morphlib/cachekeycomputer_tests.py @@ -89,12 +89,6 @@ class CacheKeyComputerTests(unittest.TestCase): self.source_pool.add(source) # FIXME: This should use MorphologyFactory m = source.morphology - if m['kind'] == 'system': - m.builds_artifacts = [m['name'] + '-rootfs'] - elif m['kind'] == 'stratum': - m.builds_artifacts = [m['name']] - elif m['kind'] == 'chunk': - m.builds_artifacts = [m['name']] self.build_env = DummyBuildEnvironment({ "LOGNAME": "foouser", "MORPH_ARCH": "dummy", -- cgit v1.2.1 From 15d1a32331883c3057fc3965b1f61dbfe0ae478d Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Wed, 10 Sep 2014 09:09:23 +0000 Subject: FIXUP: Fix up unit tests from change allowing multiple sources This is logically part of the previous patch, but has been split out to ease reviewing. --- morphlib/cachekeycomputer_tests.py | 47 +++++--------------------------------- 1 file changed, 6 insertions(+), 41 deletions(-) (limited to 'morphlib/cachekeycomputer_tests.py') diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py index 441f6123..fb5b1e28 100644 --- a/morphlib/cachekeycomputer_tests.py +++ b/morphlib/cachekeycomputer_tests.py @@ -83,10 +83,12 @@ class CacheKeyComputerTests(unittest.TestCase): - morph: stratum2 ''', }.iteritems(): - source = morphlib.source.Source( - 'repo', 'original/ref', 'sha', 'tree', - loader.load_from_string(text), name) - self.source_pool.add(source) + morph = loader.load_from_string(text) + sources = morphlib.source.make_sources('repo', 'original/ref', + name, 'sha1', + 'tree', morph) + for source in sources: + self.source_pool.add(source) # FIXME: This should use MorphologyFactory m = source.morphology self.build_env = DummyBuildEnvironment({ @@ -158,40 +160,3 @@ 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-rootfs') - morphology = old_artifact.source.morphology - new_source = morphlib.source.Source('repo', 'original/ref', 'newsha', - 'tree', morphology, - old_artifact.source.filename) - sp = morphlib.sourcepool.SourcePool() - for source in self.source_pool: - if source == old_artifact.source: - sp.add(new_source) - else: - sp.add(source) - artifacts = self.artifact_resolver.resolve_artifacts(sp) - 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) - - def test_same_morphology_added_to_source_pool_only_appears_once(self): - loader = morphlib.morphloader.MorphologyLoader() - m = loader.load_from_string( - ''' - name: chunk - kind: chunk - ''') - src = morphlib.source.Source('repo', 'original/ref', 'sha', 'tree', m, - 'chunk.morph') - sp = morphlib.sourcepool.SourcePool() - sp.add(src) - sp.add(src) - self.assertEqual(1, len([s for s in sp if s == src])) -- cgit v1.2.1 From dea5e91b2e7b109051bff68e15f8f55fe8c950bd Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Wed, 17 Sep 2014 15:07:46 +0000 Subject: FIXUP: Fix unit tests after changing to per-source builds --- morphlib/cachekeycomputer_tests.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'morphlib/cachekeycomputer_tests.py') diff --git a/morphlib/cachekeycomputer_tests.py b/morphlib/cachekeycomputer_tests.py index fb5b1e28..55936f94 100644 --- a/morphlib/cachekeycomputer_tests.py +++ b/morphlib/cachekeycomputer_tests.py @@ -123,7 +123,7 @@ class CacheKeyComputerTests(unittest.TestCase): self.ckc._hash_tuple = inccount(self.ckc._hash_tuple, 'tuple') artifact = self._find_artifact('system-rootfs') - self.ckc.compute_key(artifact) + self.ckc.compute_key(artifact.source) self.assertNotEqual(runcount['thing'], 0) self.assertNotEqual(runcount['dict'], 0) @@ -136,13 +136,13 @@ class CacheKeyComputerTests(unittest.TestCase): def test_compute_twice_same_key(self): artifact = self._find_artifact('system-rootfs') - self.assertEqual(self.ckc.compute_key(artifact), - self.ckc.compute_key(artifact)) + self.assertEqual(self.ckc.compute_key(artifact.source), + self.ckc.compute_key(artifact.source)) def test_compute_twice_same_id(self): artifact = self._find_artifact('system-rootfs') - id1 = self.ckc.get_cache_id(artifact) - id2 = self.ckc.get_cache_id(artifact) + id1 = self.ckc.get_cache_id(artifact.source) + id2 = self.ckc.get_cache_id(artifact.source) hash1 = self.ckc._hash_id(id1) hash2 = self.ckc._hash_id(id2) self.assertEqual(hash1, hash2) @@ -150,13 +150,13 @@ class CacheKeyComputerTests(unittest.TestCase): def test_compute_key_returns_sha256(self): artifact = self._find_artifact('system-rootfs') self.assertTrue(self._valid_sha256( - self.ckc.compute_key(artifact))) + self.ckc.compute_key(artifact.source))) def test_different_env_gives_different_key(self): artifact = self._find_artifact('system-rootfs') - oldsha = self.ckc.compute_key(artifact) + oldsha = self.ckc.compute_key(artifact.source) build_env = copy.deepcopy(self.build_env) build_env.env["USER"] = "brian" ckc = morphlib.cachekeycomputer.CacheKeyComputer(build_env) - self.assertNotEqual(oldsha, ckc.compute_key(artifact)) + self.assertNotEqual(oldsha, ckc.compute_key(artifact.source)) -- cgit v1.2.1