summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan van Berkom <tristan.vanberkom@codethink.co.uk>2020-06-05 20:04:30 +0900
committerTristan van Berkom <tristan.vanberkom@codethink.co.uk>2020-06-08 23:50:34 +0900
commitbcb03590e0cc787b48c92a541e2573c5586e8185 (patch)
treecb612afca6ca917b889d7e789bdf009c5cff251b
parent6c0140273156a1a8457b29286342dc27bd444db7 (diff)
downloadbuildstream-bcb03590e0cc787b48c92a541e2573c5586e8185.tar.gz
tests/format/include.py: Test including of files using full paths
-rw-r--r--tests/format/include.py21
-rw-r--r--tests/format/include/full_path/elements/element.bst6
-rw-r--r--tests/format/include/full_path/elements/invalid.bst4
-rw-r--r--tests/format/include/full_path/elements/subproject.bst5
-rw-r--r--tests/format/include/full_path/project.conf4
-rw-r--r--tests/format/include/full_path/subproject/elements/subsubproject-junction.bst5
-rw-r--r--tests/format/include/full_path/subproject/files/hello.txt1
-rw-r--r--tests/format/include/full_path/subproject/project.conf4
-rw-r--r--tests/format/include/full_path/subproject/sub.yaml1
-rw-r--r--tests/format/include/full_path/subproject/subsubproject/project.conf2
-rw-r--r--tests/format/include/full_path/subproject/subsubproject/subsub.yaml1
11 files changed, 54 insertions, 0 deletions
diff --git a/tests/format/include.py b/tests/format/include.py
index 12b043c8e..5c273e1a0 100644
--- a/tests/format/include.py
+++ b/tests/format/include.py
@@ -310,3 +310,24 @@ def test_option_from_deep_junction(cli, tmpdir, datafiles):
result.assert_success()
loaded = _yaml.load_data(result.output)
assert not loaded.get_bool("is-default")
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_include_full_path(cli, tmpdir, datafiles):
+ project = os.path.join(str(datafiles), "full_path")
+
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "element.bst"])
+ result.assert_success()
+ loaded = _yaml.load_data(result.output)
+ assert loaded.get_str("bar") == "red"
+ assert loaded.get_str("foo") == "blue"
+
+
+@pytest.mark.datafiles(DATA_DIR)
+def test_include_invalid_full_path(cli, tmpdir, datafiles):
+ project = os.path.join(str(datafiles), "full_path")
+
+ result = cli.run(project=project, args=["show", "--deps", "none", "--format", "%{vars}", "invalid.bst"])
+ result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.MISSING_FILE)
+ # Make sure the root cause provenance is in the output.
+ assert "invalid.bst [line 4 column 7]" in result.stderr
diff --git a/tests/format/include/full_path/elements/element.bst b/tests/format/include/full_path/elements/element.bst
new file mode 100644
index 000000000..7f6f08b32
--- /dev/null
+++ b/tests/format/include/full_path/elements/element.bst
@@ -0,0 +1,6 @@
+kind: manual
+
+variables:
+ (@):
+ - subproject.bst:sub.yaml
+ - subproject.bst:subsubproject-junction.bst:subsub.yaml
diff --git a/tests/format/include/full_path/elements/invalid.bst b/tests/format/include/full_path/elements/invalid.bst
new file mode 100644
index 000000000..0b5240db0
--- /dev/null
+++ b/tests/format/include/full_path/elements/invalid.bst
@@ -0,0 +1,4 @@
+kind: manual
+
+variables:
+ (@): subproject.bst:subsubproject-junction.bst:pony.yaml
diff --git a/tests/format/include/full_path/elements/subproject.bst b/tests/format/include/full_path/elements/subproject.bst
new file mode 100644
index 000000000..6664eeec6
--- /dev/null
+++ b/tests/format/include/full_path/elements/subproject.bst
@@ -0,0 +1,5 @@
+kind: junction
+
+sources:
+- kind: local
+ path: subproject
diff --git a/tests/format/include/full_path/project.conf b/tests/format/include/full_path/project.conf
new file mode 100644
index 000000000..4e2fb0063
--- /dev/null
+++ b/tests/format/include/full_path/project.conf
@@ -0,0 +1,4 @@
+name: simple
+min-version: 2.0
+
+element-path: elements
diff --git a/tests/format/include/full_path/subproject/elements/subsubproject-junction.bst b/tests/format/include/full_path/subproject/elements/subsubproject-junction.bst
new file mode 100644
index 000000000..018fb8ec4
--- /dev/null
+++ b/tests/format/include/full_path/subproject/elements/subsubproject-junction.bst
@@ -0,0 +1,5 @@
+kind: junction
+
+sources:
+- kind: local
+ path: subsubproject
diff --git a/tests/format/include/full_path/subproject/files/hello.txt b/tests/format/include/full_path/subproject/files/hello.txt
new file mode 100644
index 000000000..ce0136250
--- /dev/null
+++ b/tests/format/include/full_path/subproject/files/hello.txt
@@ -0,0 +1 @@
+hello
diff --git a/tests/format/include/full_path/subproject/project.conf b/tests/format/include/full_path/subproject/project.conf
new file mode 100644
index 000000000..1529ece04
--- /dev/null
+++ b/tests/format/include/full_path/subproject/project.conf
@@ -0,0 +1,4 @@
+name: subproject
+min-version: 2.0
+
+element-path: elements
diff --git a/tests/format/include/full_path/subproject/sub.yaml b/tests/format/include/full_path/subproject/sub.yaml
new file mode 100644
index 000000000..db3359e57
--- /dev/null
+++ b/tests/format/include/full_path/subproject/sub.yaml
@@ -0,0 +1 @@
+bar: "red"
diff --git a/tests/format/include/full_path/subproject/subsubproject/project.conf b/tests/format/include/full_path/subproject/subsubproject/project.conf
new file mode 100644
index 000000000..3b470ccf2
--- /dev/null
+++ b/tests/format/include/full_path/subproject/subsubproject/project.conf
@@ -0,0 +1,2 @@
+name: subsubproject
+min-version: 2.0
diff --git a/tests/format/include/full_path/subproject/subsubproject/subsub.yaml b/tests/format/include/full_path/subproject/subsubproject/subsub.yaml
new file mode 100644
index 000000000..4c78a1a57
--- /dev/null
+++ b/tests/format/include/full_path/subproject/subsubproject/subsub.yaml
@@ -0,0 +1 @@
+foo: "blue"