diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-03 12:52:54 +0100 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-09-04 11:00:28 +0000 |
commit | 606530b06b9ad41687da2e939ff3b8cf2fda0fa9 (patch) | |
tree | a17cb182187d3f27d7e6d41f55da912f55ea2a62 /morphlib | |
parent | 8365f330721636c9913544c73eec356b57401e78 (diff) | |
download | morph-606530b06b9ad41687da2e939ff3b8cf2fda0fa9.tar.gz |
ArtifactResolver: chunks cannot be duplicated in a stratum
We now enforce name uniqueness and don't yet implement a way of
providing an alias for chunks, so self-dependency is impossible.
Diffstat (limited to 'morphlib')
-rw-r--r-- | morphlib/artifactresolver.py | 5 | ||||
-rw-r--r-- | morphlib/artifactresolver_tests.py | 106 |
2 files changed, 54 insertions, 57 deletions
diff --git a/morphlib/artifactresolver.py b/morphlib/artifactresolver.py index aed3c9c4..4b7956e0 100644 --- a/morphlib/artifactresolver.py +++ b/morphlib/artifactresolver.py @@ -195,6 +195,7 @@ class ArtifactResolver(object): stratum.add_dependency(other_stratum) queue.append(other_source) + # 'name' here is the chunk artifact name chunk_artifacts = [] processed_artifacts = [] name_to_processed_artifact = {} @@ -223,8 +224,6 @@ class ArtifactResolver(object): if build_depends is None: for earlier_artifact in processed_artifacts: - if earlier_artifact is chunk_artifact: - continue if earlier_artifact.depends_on(chunk_artifact): raise MutualDependencyError( chunk_artifact, earlier_artifact) @@ -232,8 +231,6 @@ class ArtifactResolver(object): elif isinstance(build_depends, list): for name in build_depends: other_artifact = name_to_processed_artifact.get(name, None) - if other_artifact is chunk_artifact: - continue if other_artifact: chunk_artifact.add_dependency(other_artifact) else: diff --git a/morphlib/artifactresolver_tests.py b/morphlib/artifactresolver_tests.py index 255379a0..1371162c 100644 --- a/morphlib/artifactresolver_tests.py +++ b/morphlib/artifactresolver_tests.py @@ -669,59 +669,59 @@ class ArtifactResolverTests(unittest.TestCase): self.assertRaises(morphlib.artifactresolver.MutualDependencyError, self.resolver.resolve_artifacts, pool) - def test_graceful_handling_of_self_dependencies_of_chunks(self): - pool = morphlib.sourcepool.SourcePool() - - morph = morphlib.morph2.Morphology( - ''' - { - "name": "stratum", - "kind": "stratum", - "chunks": [ - { - "name": "chunk", - "repo": "repo", - "ref": "original/ref" - }, - { - "name": "chunk", - "repo": "repo", - "ref": "original/ref" - }, - { - "name": "chunk", - "repo": "repo", - "ref": "original/ref", - "build-depends": [ - "chunk" - ] - } - ] - } - ''') - morph.builds_artifacts = ['stratum'] - stratum = morphlib.source.Source( - 'repo', 'original/ref', 'sha1', morph, 'stratum.morph') - pool.add(stratum) - - morph = FakeChunkMorphology('chunk') - chunk = morphlib.source.Source( - 'repo', 'original/ref', 'sha1', morph, 'chunk.morph') - pool.add(chunk) - - artifacts = self.resolver.resolve_artifacts(pool) - - self.assertEqual(len(artifacts), 2) - - self.assertEqual(artifacts[0].source, stratum) - self.assertEqual(artifacts[0].name, 'stratum') - self.assertEqual(artifacts[0].dependencies, [artifacts[1]]) - self.assertEqual(artifacts[0].dependents, []) - - self.assertEqual(artifacts[1].source, chunk) - self.assertEqual(artifacts[1].name, 'chunk') - self.assertEqual(artifacts[1].dependencies, []) - self.assertEqual(artifacts[1].dependents, [artifacts[0]]) + if 0: + # This situation is currently not possible + def test_graceful_handling_of_self_dependencies_of_chunks(self): + pool = morphlib.sourcepool.SourcePool() + + morph = morphlib.morph2.Morphology( + ''' + { + "name": "stratum", + "kind": "stratum", + "chunks": [ + { + "alias": "same-chunk-runtime", + "name": "chunk-runtime", + "morph": "chunk", + "repo": "repo", + "ref": "original/ref" + }, + { + "name": "chunk-runtime", + "morph": "chunk", + "repo": "repo", + "ref": "original/ref", + "build-depends": [ + "same-chunk-runtime" + ] + } + ] + } + ''') + morph.builds_artifacts = ['stratum'] + stratum = morphlib.source.Source( + 'repo', 'original/ref', 'sha1', morph, 'stratum.morph') + pool.add(stratum) + + morph = FakeChunkMorphology('chunk') + chunk = morphlib.source.Source( + 'repo', 'original/ref', 'sha1', morph, 'chunk.morph') + pool.add(chunk) + + artifacts = self.resolver.resolve_artifacts(pool) + + self.assertEqual(len(artifacts), 2) + + self.assertEqual(artifacts[0].source, stratum) + self.assertEqual(artifacts[0].name, 'stratum') + self.assertEqual(artifacts[0].dependencies, [artifacts[1]]) + self.assertEqual(artifacts[0].dependents, []) + + self.assertEqual(artifacts[1].source, chunk) + self.assertEqual(artifacts[1].name, 'chunk') + self.assertEqual(artifacts[1].dependencies, []) + self.assertEqual(artifacts[1].dependents, [artifacts[0]]) def test_detection_of_chunk_dependencies_in_invalid_order(self): pool = morphlib.sourcepool.SourcePool() |