diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2014-08-08 07:59:02 +0000 |
---|---|---|
committer | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2014-08-08 15:22:50 +0000 |
commit | 552420219dd9275c15cf25b31e0b8355b4a72f6e (patch) | |
tree | f35a4b9c3ff6a8237233c2b765942a892481f7e5 /morphlib/morph3_tests.py | |
parent | 2fbc0825bf6d716003f602fd1c410f2d02b27576 (diff) | |
download | morph-552420219dd9275c15cf25b31e0b8355b4a72f6e.tar.gz |
morph3: Add a get_commands method to Morphology
morph2.Morphology has a `get_commands` method which is used to return
the [configure|build|install]-commands of the chunk, either by getting
them from the chunk morphology or from the build system of the chunk.
This commit implements a similar method in morph3.Morphology and adds
tests for it, so that when we remove morph2 the API changes to
morphologies are minimal.
Diffstat (limited to 'morphlib/morph3_tests.py')
-rw-r--r-- | morphlib/morph3_tests.py | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/morphlib/morph3_tests.py b/morphlib/morph3_tests.py index e150bf33..51b70597 100644 --- a/morphlib/morph3_tests.py +++ b/morphlib/morph3_tests.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013 Codethink Limited +# Copyright (C) 2013-2014 Codethink Limited # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -46,3 +46,37 @@ class MorphologyTests(unittest.TestCase): self.morph.dirty = True self.assertEqual(self.morph.dirty, True) + def test_uses_morphology_commands_when_given(self): + m = morphlib.morph3.Morphology( + { + 'name': 'foo', + 'kind': 'chunk', + 'build-system': 'dummy', + 'build-commands': ['build-it'] + } + ) + cmds = m.get_commands('build-commands') + self.assertEqual(cmds, ['build-it']) + + def test_uses_build_system_commands_when_morphology_doesnt(self): + m = morphlib.morph3.Morphology( + { + 'name': 'foo', + 'kind': 'chunk', + 'build-system': 'dummy', + } + ) + cmds = m.get_commands('build-commands') + self.assertEqual(cmds, ['echo dummy build']) + + def test_uses_morphology_commands_when_morphology_has_empty_list(self): + m = morphlib.morph3.Morphology( + { + 'name': 'foo', + 'kind': 'chunk', + 'build-system': 'dummy', + 'build-commands': [] + } + ) + cmds = m.get_commands('build-commands') + self.assertEqual(cmds, []) |