This is an automated email from the ASF dual-hosted git repository. tvb pushed a commit to branch tristan/strict-element-names in repository https://gitbox.apache.org/repos/asf/buildstream.git
commit c9bcda68f21d74086cd4886c7c2c9d89e1ca2255 Author: Tristan van Berkom <[email protected]> AuthorDate: Sun Oct 10 14:39:02 2021 +0900 tests/format/elementnames.py: Added format test for element names Ensure that we emit the correct errors for bad element names, either on the command line or as specified as dependencies in the yaml. --- tests/format/elementnames.py | 29 ++++++++++++++++++++++++++++ tests/format/elementnames/bad-chars-dep.bst | 3 +++ tests/format/elementnames/bad-suffix-dep.bst | 3 +++ tests/format/elementnames/project.conf | 4 ++++ 4 files changed, 39 insertions(+) diff --git a/tests/format/elementnames.py b/tests/format/elementnames.py new file mode 100644 index 0000000..f059d54 --- /dev/null +++ b/tests/format/elementnames.py @@ -0,0 +1,29 @@ +# 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 import cli # pylint: disable=unused-import + +DATA_DIR = os.path.dirname(os.path.realpath(__file__)) + + [email protected]( + "target,reason,provenance", + [ + ("farm.pony", LoadErrorReason.BAD_ELEMENT_SUFFIX, None), + ('The "quoted" pony.bst', LoadErrorReason.BAD_CHARACTERS_IN_NAME, None), + ("bad-suffix-dep.bst", LoadErrorReason.BAD_ELEMENT_SUFFIX, "bad-suffix-dep.bst [line 3 column 2]"), + ("bad-chars-dep.bst", LoadErrorReason.BAD_CHARACTERS_IN_NAME, "bad-chars-dep.bst [line 3 column 2]"), + ], + ids=["toplevel-bad-suffix", "toplevel-bad-chars", "dependency-bad-suffix", "dependency-bad-chars"], +) [email protected](DATA_DIR) +def test_invalid_element_names(cli, datafiles, target, reason, provenance): + project = os.path.join(str(datafiles), "elementnames") + result = cli.run(project=project, silent=True, args=["show", target]) + result.assert_main_error(ErrorDomain.LOAD, reason) + if provenance: + assert provenance in result.stderr diff --git a/tests/format/elementnames/bad-chars-dep.bst b/tests/format/elementnames/bad-chars-dep.bst new file mode 100644 index 0000000..d637799 --- /dev/null +++ b/tests/format/elementnames/bad-chars-dep.bst @@ -0,0 +1,3 @@ +kind: stack +depends: +- <invalid>.bst diff --git a/tests/format/elementnames/bad-suffix-dep.bst b/tests/format/elementnames/bad-suffix-dep.bst new file mode 100644 index 0000000..c96604d --- /dev/null +++ b/tests/format/elementnames/bad-suffix-dep.bst @@ -0,0 +1,3 @@ +kind: stack +depends: +- rainbow.pony diff --git a/tests/format/elementnames/project.conf b/tests/format/elementnames/project.conf new file mode 100644 index 0000000..b0110aa --- /dev/null +++ b/tests/format/elementnames/project.conf @@ -0,0 +1,4 @@ +# Basic project configuration that doesnt override anything +# +name: test +min-version: 2.0
