From a5fc384165d905b1cb1a084f9040b2cd3de472db Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Tue, 12 Aug 2014 16:02:50 +0000 Subject: fixup: Load commands at Morphology construction --- morphlib/builder2.py | 2 +- morphlib/cachekeycomputer.py | 2 +- morphlib/morphloader.py | 8 ++++++++ morphlib/morphologyfactory.py | 1 + morphlib/morphologyfactory_tests.py | 6 +++--- 5 files changed, 14 insertions(+), 5 deletions(-) diff --git a/morphlib/builder2.py b/morphlib/builder2.py index d739dc13..c1a49221 100644 --- a/morphlib/builder2.py +++ b/morphlib/builder2.py @@ -405,7 +405,7 @@ class ChunkBuilder(BuilderBase): for step, in_parallel in steps: with self.build_watch(step): key = '%s-commands' % step - cmds = m.get_commands(key) + cmds = m[key] if cmds: with open(logfilepath, 'a') as log: self.app.status(msg='Running %(key)s', key=key) diff --git a/morphlib/cachekeycomputer.py b/morphlib/cachekeycomputer.py index 292047c8..588fc8d3 100644 --- a/morphlib/cachekeycomputer.py +++ b/morphlib/cachekeycomputer.py @@ -114,7 +114,7 @@ class CacheKeyComputer(object): for prefix in ('pre-', '', 'post-'): for cmdtype in ('configure', 'build', 'test', 'install'): cmd_field = prefix + cmdtype + '-commands' - keys[cmd_field] = morphology.get_commands(cmd_field) + keys[cmd_field] = morphology[cmd_field] keys['devices'] = morphology.get('devices') keys['max-jobs'] = morphology.get('max-jobs') keys['system-integration'] = morphology.get('system-integration', diff --git a/morphlib/morphloader.py b/morphlib/morphloader.py index 1300f78e..351977c4 100644 --- a/morphlib/morphloader.py +++ b/morphlib/morphloader.py @@ -407,6 +407,7 @@ class MorphologyLoader(object): m.filename = filename self.validate(m) self.set_defaults(m) + self.set_commands(m) return m def load_from_file(self, filename): @@ -754,3 +755,10 @@ class MorphologyLoader(object): if morph['max-jobs'] is not None: morph['max-jobs'] = int(morph['max-jobs']) + def set_commands(self, morph): + if morph['kind'] == 'chunk': + steps = [key for key, value in morph.iteritems() + if 'commands' in key] + for key in steps: + if morph[key] == self._static_defaults['chunk'][key]: + morph[key] = morph.get_commands(key) diff --git a/morphlib/morphologyfactory.py b/morphlib/morphologyfactory.py index 7d23f113..f4ee57c7 100644 --- a/morphlib/morphologyfactory.py +++ b/morphlib/morphologyfactory.py @@ -86,6 +86,7 @@ class MorphologyFactory(object): morph = bs.get_morphology(morph_name) loader.set_defaults(morph) loader.validate(morph) + loader.set_commands(morph) return morph def get_morphology(self, reponame, sha1, filename): diff --git a/morphlib/morphologyfactory_tests.py b/morphlib/morphologyfactory_tests.py index 347d93f7..0a3bddd6 100644 --- a/morphlib/morphologyfactory_tests.py +++ b/morphlib/morphologyfactory_tests.py @@ -30,7 +30,7 @@ class FakeRemoteRepoCache(object): return '''{ "name": "%s", "kind": "chunk", - "build-system": "bar" + "build-system": "dummy" }''' % filename[:-len('.morph')] return 'text' @@ -43,12 +43,12 @@ class FakeLocalRepo(object): 'chunk.morph': ''' name: chunk kind: chunk - build-system: bar + build-system: dummy ''', 'chunk-split.morph': ''' name: chunk-split kind: chunk - build-system: bar + build-system: dummy products: - artifact: chunk-split-runtime include: [] -- cgit v1.2.1