summaryrefslogtreecommitdiff
path: root/morphlib/morphologyfactory.py
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2013-08-07 12:00:49 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2013-08-07 13:41:40 +0100
commit40be81b74d63e1ba7bd3e10a78c79d3829673172 (patch)
tree1c88237b7431c734ec515df2067ad15e06327c80 /morphlib/morphologyfactory.py
parent66291811c81ed21f5005ba35e68898c73edd88bd (diff)
downloadmorph-40be81b74d63e1ba7bd3e10a78c79d3829673172.tar.gz
morphologyfactory: move empty stratum check here
It is better to test whether a straum is empty here, since it will be noticed earlier in the build, as soon as the morphologies are loaded, rather than after they have all been parsed. It is also conceptually nicer to put it here, since the morphologyfactory was written to perform this kind of validation. On a more practical note, the validation is moved here so that the test for this error isn't masked by the test for no build dependencies. To ensure tests still pass, we alter the stratum morphology used by other unit tests to no longer be empty, and add an empty one to test.
Diffstat (limited to 'morphlib/morphologyfactory.py')
-rw-r--r--morphlib/morphologyfactory.py10
1 files changed, 10 insertions, 0 deletions
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'))