Skip to content
Snippets Groups Projects
Commit bbe7c846 authored by Phillip Smyth's avatar Phillip Smyth
Browse files

tests/frontend: Add test for invalid element-path

parent 239e8113
No related branches found
No related tags found
No related merge requests found
Pipeline #35910778 failed
......@@ -219,6 +219,19 @@ class Project():
return self._cache_key
def validate_nodes(self, node):
_yaml.node_validate(node, [
'format-version',
'element-path', 'variables',
'environment', 'environment-nocache',
'split-rules', 'elements', 'plugins',
'aliases', 'name',
'artifacts', 'options',
'fail-on-overlap', 'shell', 'fatal-warnings',
'(@)', 'sources',
'ref-storage', 'sandbox', 'mirrors', 'remote-execution'
])
# create_element()
#
# Instantiate and return an element
......@@ -402,17 +415,7 @@ class Project():
"Project requested format version {}, but BuildStream {}.{} only supports up until format version {}"
.format(format_version, major, minor, BST_FORMAT_VERSION))
_yaml.node_validate(pre_config_node, [
'format-version',
'element-path', 'variables',
'environment', 'environment-nocache',
'split-rules', 'elements', 'plugins',
'aliases', 'name',
'artifacts', 'options',
'fail-on-overlap', 'shell', 'fatal-warnings',
'(@)', 'sources',
'ref-storage', 'sandbox', 'mirrors', 'remote-execution'
])
self.validate_nodes(pre_config_node)
# FIXME:
#
......@@ -479,16 +482,7 @@ class Project():
self._load_pass(config, self.config)
_yaml.node_validate(config, [
'format-version',
'element-path', 'variables',
'environment', 'environment-nocache',
'split-rules', 'elements', 'plugins',
'aliases', 'name',
'artifacts', 'options',
'fail-on-overlap', 'shell', 'fatal-warnings',
'ref-storage', 'sandbox', 'mirrors', 'remote-execution'
])
self.validate_nodes(config)
#
# Now all YAML composition is done, from here on we just load
......
# Project config for frontend build test
name: test
elephant-path: elements
......@@ -36,6 +36,19 @@ def test_show(cli, datafiles, target, format, expected):
.format(expected, result.output))
@pytest.mark.datafiles(os.path.join(
os.path.dirname(os.path.realpath(__file__)),
"invalid_element_path",
))
def test_show_invalid_element_path(cli, datafiles):
project = os.path.join(datafiles.dirname, datafiles.basename)
result = cli.run(project=project, silent=True, args=[
'show',
"foo.bst"])
result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
@pytest.mark.datafiles(DATA_DIR)
@pytest.mark.parametrize("target,except_,expected", [
('target.bst', 'import-bin.bst', ['import-dev.bst', 'compose-all.bst', 'target.bst']),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment