summaryrefslogtreecommitdiff
path: root/morphlib
diff options
context:
space:
mode:
authorJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-04-16 19:11:23 +0100
committerJannis Pohlmann <jannis.pohlmann@codethink.co.uk>2012-04-16 19:11:23 +0100
commit84e51a23a2ed2b9aeac03fc8f08050ecfc56ab4d (patch)
treeceecf3ca405c9007df7b8857d499cae595f6aa34 /morphlib
parentd2d2007a322c8187f20ac8c1a0ee6fcb3bd9bc24 (diff)
downloadmorph-84e51a23a2ed2b9aeac03fc8f08050ecfc56ab4d.tar.gz
Remove buggy cyclic dependency chain check from ArtifactResolver.
However, leave a TODO note that we really want this in the source.
Diffstat (limited to 'morphlib')
-rw-r--r--morphlib/artifactresolver.py43
-rw-r--r--morphlib/artifactresolver_tests.py67
-rw-r--r--morphlib/buildorder_tests.py2
3 files changed, 6 insertions, 106 deletions
diff --git a/morphlib/artifactresolver.py b/morphlib/artifactresolver.py
index f8ae4399..808f7119 100644
--- a/morphlib/artifactresolver.py
+++ b/morphlib/artifactresolver.py
@@ -27,13 +27,6 @@ class MutualDependencyError(cliapp.AppException):
self, 'Cyclic dependency between %s and %s detected' % (a, b))
-class CyclicDependencyChainError(cliapp.AppException):
-
- def __init__(self):
- cliapp.AppException.__init__(
- self, 'Cyclic dependency chain detected')
-
-
class DependencyOrderError(cliapp.AppException):
def __init__(self, stratum, chunk, dependency_name):
@@ -89,7 +82,8 @@ class ArtifactResolver(object):
self._added_artifacts = set()
artifacts = self._resolve_artifacts_recursively()
- self._detect_cyclic_dependencies(artifacts)
+ # TODO perform cycle detection, e.g. based on:
+ # http://stackoverflow.com/questions/546655/finding-all-cycles-in-graph
return artifacts
def _resolve_artifacts_recursively(self):
@@ -258,36 +252,7 @@ class ArtifactResolver(object):
return artifacts
def _chunk_artifact_names(self, source):
- if 'artifacts' in source.morphology:
- return sorted(source.morphology['artifacts'].keys())
+ if 'chunks' in source.morphology:
+ return sorted(source.morphology['chunks'].keys())
else:
return [source.morphology['name']]
-
- def _detect_cyclic_dependencies(self, artifacts):
- # FIXME This is not well tested and might be incorrect. Better
- # something based on
- # http://stackoverflow.com/questions/546655/finding-all-cycles-in-graph
-
- visited = set()
- explored = set()
- parent = {}
-
- roots = []
- for artifact in artifacts:
- if len(artifact.dependents) == 0:
- roots.append(artifact)
- parent[artifact] = None
-
- stack = collections.deque(roots)
- while stack:
- artifact = stack.popleft()
- visited.add(artifact)
-
- for dependency in artifact.dependencies:
- if not (artifact, dependency) in explored:
- explored.add((artifact, dependency))
- parent[dependency] = artifact
- if not dependency in visited:
- stack.appendleft(dependency)
- else:
- raise CyclicDependencyChainError()
diff --git a/morphlib/artifactresolver_tests.py b/morphlib/artifactresolver_tests.py
index 68a2c886..d77ff5bb 100644
--- a/morphlib/artifactresolver_tests.py
+++ b/morphlib/artifactresolver_tests.py
@@ -41,7 +41,7 @@ class FakeChunkMorphology(morphlib.morph2.Morphology):
{
"name": "%s",
"kind": "chunk",
- "artifacts": %s
+ "chunks": %s
}
''' % (name, json.dumps(artifacts)))
else:
@@ -699,71 +699,6 @@ class ArtifactResolverTests(unittest.TestCase):
self.assertEqual(artifacts[1].dependencies, [])
self.assertEqual(artifacts[1].dependents, [artifacts[0]])
- def test_detection_of_cyclic_chunk_dependency_chain(self):
- pool = morphlib.sourcepool.SourcePool()
-
- morph = morphlib.morph2.Morphology(
- '''
- {
- "name": "stratum1",
- "kind": "stratum",
- "sources": [
- {
- "name": "chunk1",
- "repo": "repo",
- "ref": "original/ref"
- },
- {
- "name": "chunk2",
- "repo": "repo",
- "ref": "original/ref",
- "build-depends": [
- "chunk1"
- ]
- },
- {
- "name": "chunk3",
- "repo": "repo",
- "ref": "original/ref",
- "build-depends": [
- "chunk2"
- ]
- }
- ]
- }
- ''')
- stratum1 = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', morph, 'stratum1.morph')
- pool.add(stratum1)
-
- morph = FakeStratumMorphology(
- 'stratum2', [
- ('chunk3', 'chunk3', 'repo', 'original/ref'),
- ('chunk1', 'chunk1', 'repo', 'original/ref')
- ], ['stratum1'])
- stratum2 = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', morph, 'stratum2.morph')
- pool.add(stratum2)
-
- morph = FakeChunkMorphology('chunk1')
- chunk1 = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', morph, 'chunk1.morph')
- pool.add(chunk1)
-
- morph = FakeChunkMorphology('chunk2')
- chunk2 = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', morph, 'chunk2.morph')
- pool.add(chunk2)
-
- morph = FakeChunkMorphology('chunk3')
- chunk3 = morphlib.source.Source(
- 'repo', 'original/ref', 'sha1', morph, 'chunk3.morph')
- pool.add(chunk3)
-
- self.assertRaises(
- morphlib.artifactresolver.CyclicDependencyChainError,
- self.resolver.resolve_artifacts, pool)
-
def test_detection_of_chunk_dependencies_in_invalid_order(self):
pool = morphlib.sourcepool.SourcePool()
diff --git a/morphlib/buildorder_tests.py b/morphlib/buildorder_tests.py
index 162c4d85..67fbdf4f 100644
--- a/morphlib/buildorder_tests.py
+++ b/morphlib/buildorder_tests.py
@@ -122,7 +122,7 @@ class BuildOrderTests(unittest.TestCase):
self.assertEqual(order.groups[0], [artifact1, artifact2])
self.assertEqual(order.groups[1], [artifact3])
- def test_detection_of_cyclic_dependency(self):
+ def test_detection_of_cyclic_dependency_chain(self):
chunk1 = FakeSource()
artifact1 = morphlib.artifact.Artifact(chunk1, 'chunk1', 'key1')