From 0aca836471655e305ed075e374d04f0c657789ee Mon Sep 17 00:00:00 2001 From: James Ennis Date: Thu, 15 Aug 2019 17:00:10 +0100 Subject: invalid_keys.py: Test compositied nodes are reported back usefully Test that we get the correct provenance from a node which has been compositied. This tests asserts that if we forget to include one of the local plugin's essential keys, we fail and see the appropriate error message. Tests issue described in #1059. --- tests/format/invalid-keys/no-path-specified.bst | 4 ++++ tests/format/invalid-keys/project.conf | 1 + tests/format/invalid_keys.py | 23 +++++++++++++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 tests/format/invalid-keys/no-path-specified.bst create mode 100644 tests/format/invalid-keys/project.conf create mode 100644 tests/format/invalid_keys.py diff --git a/tests/format/invalid-keys/no-path-specified.bst b/tests/format/invalid-keys/no-path-specified.bst new file mode 100644 index 000000000..85570b64d --- /dev/null +++ b/tests/format/invalid-keys/no-path-specified.bst @@ -0,0 +1,4 @@ +kind: import + +sources: + - kind: local diff --git a/tests/format/invalid-keys/project.conf b/tests/format/invalid-keys/project.conf new file mode 100644 index 000000000..b32753625 --- /dev/null +++ b/tests/format/invalid-keys/project.conf @@ -0,0 +1 @@ +name: test diff --git a/tests/format/invalid_keys.py b/tests/format/invalid_keys.py new file mode 100644 index 000000000..12e07b01b --- /dev/null +++ b/tests/format/invalid_keys.py @@ -0,0 +1,23 @@ +# Pylint doesn't play well with fixtures and dependency injection from pytest +# pylint: disable=redefined-outer-name + +import os +import pytest +from buildstream._exceptions import ErrorDomain, LoadErrorReason +from buildstream.testing.runcli import cli # pylint: disable=unused-import + +# Project directory +DATA_DIR = os.path.join( + os.path.dirname(os.path.realpath(__file__)), + 'invalid-keys' +) + + +@pytest.mark.datafiles(DATA_DIR) +def test_compositied_node_fails_usefully(cli, datafiles): + project = str(datafiles) + result = cli.run(project=project, args=['show', 'no-path-specified.bst']) + result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA) + + assert "synthetic node" not in result.stderr + assert "no-path-specified.bst [line 4 column 4]: Dictionary did not contain expected key 'path'" in result.stderr -- cgit v1.2.1