diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-10-23 19:30:02 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-10-23 19:30:02 +0900 |
commit | 6173a3f1ca6fd5ac6d635f4d9b5d82fccddc37a4 (patch) | |
tree | 4de15900c1a0320ced09a9fada43b4cb9f67c7b3 /tests | |
parent | 041961374b799e3369563538a3a6d6f14237c157 (diff) | |
download | buildstream-6173a3f1ca6fd5ac6d635f4d9b5d82fccddc37a4.tar.gz |
tests/format: Test proper failure of reference to undefined options
When using an undefined option in a conditional expression, buildstream
should error out and print a good message about it.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/format/options.py | 15 | ||||
-rw-r--r-- | tests/format/options/undefined-variable/element.bst | 2 | ||||
-rw-r--r-- | tests/format/options/undefined-variable/project.conf | 12 |
3 files changed, 29 insertions, 0 deletions
diff --git a/tests/format/options.py b/tests/format/options.py index dfc2b8340..5cb01622c 100644 --- a/tests/format/options.py +++ b/tests/format/options.py @@ -83,6 +83,21 @@ def test_invalid_expression(cli, datafiles): @pytest.mark.datafiles(DATA_DIR) +def test_undefined(cli, datafiles): + project = os.path.join(datafiles.dirname, datafiles.basename, 'undefined-variable') + result = cli.run(project=project, silent=True, args=[ + 'show', + '--deps', 'none', + '--format', '%{vars}', + 'element.bst']) + + assert result.exit_code != 0 + assert result.exception + assert isinstance(result.exception, LoadError) + assert result.exception.reason == LoadErrorReason.EXPRESSION_FAILED + + +@pytest.mark.datafiles(DATA_DIR) def test_invalid_condition(cli, datafiles): project = os.path.join(datafiles.dirname, datafiles.basename, 'invalid-condition') result = cli.run(project=project, silent=True, args=[ diff --git a/tests/format/options/undefined-variable/element.bst b/tests/format/options/undefined-variable/element.bst new file mode 100644 index 000000000..e006c8a96 --- /dev/null +++ b/tests/format/options/undefined-variable/element.bst @@ -0,0 +1,2 @@ +kind: autotools + diff --git a/tests/format/options/undefined-variable/project.conf b/tests/format/options/undefined-variable/project.conf new file mode 100644 index 000000000..d634ef0a4 --- /dev/null +++ b/tests/format/options/undefined-variable/project.conf @@ -0,0 +1,12 @@ +name: test + +options: + pony: + type: bool + description: Whether a pony + default: False + +variables: + (?): + - pony == foo: + prefix: "/opt" |