diff options
Diffstat (limited to 'morphlib')
-rw-r--r-- | morphlib/builder2.py | 9 | ||||
-rw-r--r-- | morphlib/morphologyfactory.py | 10 | ||||
-rw-r--r-- | morphlib/morphologyfactory_tests.py | 19 |
3 files changed, 28 insertions, 10 deletions
diff --git a/morphlib/builder2.py b/morphlib/builder2.py index daf50b56..e1eaaa86 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -469,8 +469,6 @@ class StratumBuilder(BuilderBase): with self.build_watch('overall-build'): constituents = [d for d in self.artifact.dependencies if self.is_constituent(d)] - if len(constituents) == 0: - raise EmptyStratumError(self.artifact.name) # the only reason the StratumBuilder has to download chunks is to # check for overlap now that strata are lists of chunks @@ -707,10 +705,3 @@ class Builder(object): # pragma: no cover built_artifacts = o.build_and_cache() logging.debug('Builder.build: done') return built_artifacts - - -class EmptyStratumError(cliapp.AppException): - - def __init__(self, stratum_name): # pragma: no cover - cliapp.AppException.__init__(self, - "Stratum %s is empty (has no dependencies)" % stratum_name) diff --git a/morphlib/morphologyfactory.py b/morphlib/morphologyfactory.py index 394d186a..fa71e820 100644 --- a/morphlib/morphologyfactory.py +++ b/morphlib/morphologyfactory.py @@ -47,6 +47,13 @@ class NoChunkBuildDependsError(StratumError): '(build-depends is a mandatory field)' % (stratum, chunk)) +class EmptyStratumError(StratumError): + + def __init__(self, stratum): + cliapp.AppException.__init__(self, + "Stratum %s is empty (has no dependencies)" % stratum) + + class MorphologyFactory(object): '''An way of creating morphologies which will provide a default''' @@ -147,6 +154,9 @@ class MorphologyFactory(object): def _check_and_tweak_stratum(self, morphology, reponame, sha1, filename): '''Check and tweak a stratum morphology.''' + if len(morphology['chunks']) == 0: + raise EmptyStratumError(morphology['name']) + for source in morphology['chunks']: if source.get('build-depends', None) is None: name = source.get('name', source.get('repo', 'unknown')) diff --git a/morphlib/morphologyfactory_tests.py b/morphlib/morphologyfactory_tests.py index 7a3dc343..de1be017 100644 --- a/morphlib/morphologyfactory_tests.py +++ b/morphlib/morphologyfactory_tests.py @@ -57,7 +57,15 @@ class FakeLocalRepo(object): }''', 'stratum.morph': '''{ "name": "stratum", - "kind": "stratum" + "kind": "stratum", + "chunks": [ + { + "name": "chunk", + "repo": "test:repo", + "ref": "sha1", + "build-depends": [] + } + ] }''', 'stratum-no-chunk-bdeps.morph': '''{ "name": "stratum-no-chunk-bdeps", @@ -71,6 +79,10 @@ class FakeLocalRepo(object): } ] }''', + 'stratum-empty.morph': '''{ + "name": "stratum-empty", + "kind": "stratum" + }''', 'system.morph': '''{ "name": "system", "kind": "system", @@ -278,3 +290,8 @@ class MorphologyFactoryTests(unittest.TestCase): self.mf.get_morphology, 'reponame', 'sha1', 'stratum-no-chunk-bdeps.morph') + def test_fails_on_empty_stratum(self): + self.assertRaises( + morphlib.morphologyfactory.EmptyStratumError, + self.mf.get_morphology, 'reponame', 'sha1', 'stratum-empty.morph') + |