summaryrefslogtreecommitdiff
path: root/morphlib/morphloader_tests.py
diff options
context:
space:
mode:
authorAdam Coldrick <adam@sotk.co.uk>2015-05-06 20:43:13 +0000
committerBaserock Gerrit <gerrit@baserock.org>2015-05-08 08:09:52 +0000
commitf9a0607b654ee1adb85f4c1bfedd3571a22ac21a (patch)
tree1d8b32ed5793f71c090883b9fa9c97a410f6ca11 /morphlib/morphloader_tests.py
parent4c0d2a9f9c3b71345d1a59a403c81d2795917a75 (diff)
downloadmorph-f9a0607b654ee1adb85f4c1bfedd3571a22ac21a.tar.gz
Raise an error if a stratum build-depends on itself
If a stratum build-depends on itself, the build graph calculation gets stuck in an infinite loop as it adds the same stratum to the queue of morphologies to inspect over and over again. This commit causes MorphologyLoader.validate_stratum to raise an error if a stratum contains itself in it's build-depends, as depending on itself makes no sense and will cause the above problem. Change-Id: I76df5b7d63d010ae3b17f72bfa39b273e74279dd
Diffstat (limited to 'morphlib/morphloader_tests.py')
-rw-r--r--morphlib/morphloader_tests.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/morphlib/morphloader_tests.py b/morphlib/morphloader_tests.py
index f9fa2a34..db1872a8 100644
--- a/morphlib/morphloader_tests.py
+++ b/morphlib/morphloader_tests.py
@@ -225,6 +225,20 @@ build-system: dummy
morphlib.morphloader.EmptyRefError):
self.loader.validate(m)
+ def test_fails_to_validate_stratum_which_build_depends_on_self(self):
+ text = '''\
+name: bad-stratum
+kind: stratum
+build-depends:
+- morph: strata/bad-stratum.morph
+chunks:
+- name: chunk
+ repo: test:repo
+ ref: foo'''
+ self.assertRaises(
+ morphlib.morphloader.DependsOnSelfError,
+ self.loader.load_from_string, text, 'strata/bad-stratum.morph')
+
def test_fails_to_validate_system_with_obsolete_system_kind_field(self):
m = morphlib.morphology.Morphology({
'kind': 'system',