summaryrefslogtreecommitdiff
path: root/tests/format
diff options
context:
space:
mode:
authorJames Ennis <james.ennis@codethink.co.uk>2019-02-28 17:59:32 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-03-12 14:22:08 +0000
commit416a331b6f840f5f0f0e9ee78adf13823d6630bf (patch)
tree1800a0d5bc54304e146cb71d256dc9cb05191fe3 /tests/format
parenta424d33f3c50de8c95e6b15ed9bf2689e545e5bc (diff)
downloadbuildstream-416a331b6f840f5f0f0e9ee78adf13823d6630bf.tar.gz
tests: Add tests to ensure that overwriting on later compositions works
Diffstat (limited to 'tests/format')
-rw-r--r--tests/format/include.py17
-rw-r--r--tests/format/include/eventual_overrides/element.bst11
-rw-r--r--tests/format/include/eventual_overrides/extra_conf.yml8
-rw-r--r--tests/format/include/eventual_overrides/extra_conf2.yml2
-rw-r--r--tests/format/include/eventual_overrides/project.conf1
-rw-r--r--tests/format/include_composition.py24
6 files changed, 63 insertions, 0 deletions
diff --git a/tests/format/include.py b/tests/format/include.py
index 83e19ad28..d065f2447 100644
--- a/tests/format/include.py
+++ b/tests/format/include.py
@@ -199,6 +199,23 @@ def test_include_element_overrides_composition(cli, datafiles):
@pytest.mark.datafiles(DATA_DIR)
+def test_list_overide_does_not_fail_upon_first_composition(cli, datafiles):
+ project = os.path.join(str(datafiles), 'eventual_overrides')
+
+ result = cli.run(project=project, args=[
+ 'show',
+ '--deps', 'none',
+ '--format', '%{public}',
+ 'element.bst'])
+ result.assert_success()
+ loaded = _yaml.load_data(result.output)
+
+ # Assert that the explicitly overwritten public data is present
+ assert 'foo-commands' in loaded['bst']
+ assert loaded['bst']['foo-commands'] == ['need', 'this']
+
+
+@pytest.mark.datafiles(DATA_DIR)
def test_include_element_overrides_sub_include(cli, datafiles):
project = os.path.join(str(datafiles), 'sub-include')
diff --git a/tests/format/include/eventual_overrides/element.bst b/tests/format/include/eventual_overrides/element.bst
new file mode 100644
index 000000000..cd1fc9f51
--- /dev/null
+++ b/tests/format/include/eventual_overrides/element.bst
@@ -0,0 +1,11 @@
+kind: manual
+public:
+ bst:
+ foo-commands:
+ (=):
+ - need
+ - this
+
+(@):
+ - extra_conf.yml
+ - extra_conf2.yml
diff --git a/tests/format/include/eventual_overrides/extra_conf.yml b/tests/format/include/eventual_overrides/extra_conf.yml
new file mode 100644
index 000000000..8436310a0
--- /dev/null
+++ b/tests/format/include/eventual_overrides/extra_conf.yml
@@ -0,0 +1,8 @@
+public:
+ bst:
+ foo-commands:
+ - wrong
+ - commands
+
+variables:
+ included: 'True'
diff --git a/tests/format/include/eventual_overrides/extra_conf2.yml b/tests/format/include/eventual_overrides/extra_conf2.yml
new file mode 100644
index 000000000..88d469605
--- /dev/null
+++ b/tests/format/include/eventual_overrides/extra_conf2.yml
@@ -0,0 +1,2 @@
+variables:
+ included: 'False'
diff --git a/tests/format/include/eventual_overrides/project.conf b/tests/format/include/eventual_overrides/project.conf
new file mode 100644
index 000000000..b32753625
--- /dev/null
+++ b/tests/format/include/eventual_overrides/project.conf
@@ -0,0 +1 @@
+name: test
diff --git a/tests/format/include_composition.py b/tests/format/include_composition.py
index b73fca392..5a060132a 100644
--- a/tests/format/include_composition.py
+++ b/tests/format/include_composition.py
@@ -129,3 +129,27 @@ def test_main_keeps_keys(tmpdir):
assert main['test'] == ['a']
assert main['something'] == 'else'
+
+
+def test_overwrite_directive_on_later_composite(tmpdir):
+ includes = make_includes(str(tmpdir))
+
+ _yaml.dump({'(@)': ['a.yml', 'b.yml'],
+ 'test': {'(=)': ['Overwritten']}},
+ str(tmpdir.join('main.yml')))
+
+ main = _yaml.load(str(tmpdir.join('main.yml')))
+
+ # a.yml
+ _yaml.dump({'test': ['some useless', 'list', 'to be overwritten'],
+ 'foo': 'should not be present'},
+ str(tmpdir.join('a.yml')))
+
+ # b.yaml isn't going to have a 'test' node to overwrite
+ _yaml.dump({'foo': 'should be present'},
+ str(tmpdir.join('b.yml')))
+
+ includes.process(main)
+
+ assert main['test'] == ['Overwritten']
+ assert main['foo'] == 'should be present'