diff options
author | Tristan van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-06-05 20:04:30 +0900 |
---|---|---|
committer | Tristan van Berkom <tristan.vanberkom@codethink.co.uk> | 2020-06-05 20:08:31 +0900 |
commit | b7a1b28c4b70fffe0c338c9ab5f1fbe9d31d1eaa (patch) | |
tree | f78dd887c65eafb28ec4f2099df8cf8d2d1d7c99 | |
parent | f93268269afd67b8e1b77ce874ad2a4814fe6a54 (diff) | |
download | buildstream-b7a1b28c4b70fffe0c338c9ab5f1fbe9d31d1eaa.tar.gz |
tests/format/include.py: Test including of files using full paths
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" |