Phillip Smyth pushed to branch element-path_not_validated at BuildStream / buildstream
Commits:
3 changed files:
Changes:
| ... | ... | @@ -219,6 +219,19 @@ class Project(): | 
| 219 | 219 |  | 
| 220 | 220 |          return self._cache_key
 | 
| 221 | 221 |  | 
| 222 | +    def validate_nodes(self, node):
 | |
| 223 | +        _yaml.node_validate(node, [
 | |
| 224 | +            'format-version',
 | |
| 225 | +            'element-path', 'variables',
 | |
| 226 | +            'environment', 'environment-nocache',
 | |
| 227 | +            'split-rules', 'elements', 'plugins',
 | |
| 228 | +            'aliases', 'name',
 | |
| 229 | +            'artifacts', 'options',
 | |
| 230 | +            'fail-on-overlap', 'shell', 'fatal-warnings',
 | |
| 231 | +            '(@)', 'sources',
 | |
| 232 | +            'ref-storage', 'sandbox', 'mirrors', 'remote-execution'
 | |
| 233 | +        ])
 | |
| 234 | + | |
| 222 | 235 |      # create_element()
 | 
| 223 | 236 |      #
 | 
| 224 | 237 |      # Instantiate and return an element
 | 
| ... | ... | @@ -402,6 +415,8 @@ class Project(): | 
| 402 | 415 |                  "Project requested format version {}, but BuildStream {}.{} only supports up until format version {}"
 | 
| 403 | 416 |                  .format(format_version, major, minor, BST_FORMAT_VERSION))
 | 
| 404 | 417 |  | 
| 418 | +        self.validate_nodes(pre_config_node)
 | |
| 419 | + | |
| 405 | 420 |          # FIXME:
 | 
| 406 | 421 |          #
 | 
| 407 | 422 |          #   Performing this check manually in the absense
 | 
| ... | ... | @@ -467,16 +482,7 @@ class Project(): | 
| 467 | 482 |  | 
| 468 | 483 |          self._load_pass(config, self.config)
 | 
| 469 | 484 |  | 
| 470 | -        _yaml.node_validate(config, [
 | |
| 471 | -            'format-version',
 | |
| 472 | -            'element-path', 'variables',
 | |
| 473 | -            'environment', 'environment-nocache',
 | |
| 474 | -            'split-rules', 'elements', 'plugins',
 | |
| 475 | -            'aliases', 'name',
 | |
| 476 | -            'artifacts', 'options',
 | |
| 477 | -            'fail-on-overlap', 'shell', 'fatal-warnings',
 | |
| 478 | -            'ref-storage', 'sandbox', 'mirrors', 'remote-execution'
 | |
| 479 | -        ])
 | |
| 485 | +        self.validate_nodes(config)
 | |
| 480 | 486 |  | 
| 481 | 487 |          #
 | 
| 482 | 488 |          # Now all YAML composition is done, from here on we just load
 | 
| 1 | +# Project config for frontend build test
 | |
| 2 | +name: test
 | |
| 3 | + | |
| 4 | +elephant-path: elements | 
| ... | ... | @@ -36,6 +36,19 @@ def test_show(cli, datafiles, target, format, expected): | 
| 36 | 36 |                               .format(expected, result.output))
 | 
| 37 | 37 |  | 
| 38 | 38 |  | 
| 39 | +@pytest.mark.datafiles(os.path.join(
 | |
| 40 | +    os.path.dirname(os.path.realpath(__file__)),
 | |
| 41 | +    "invalid_element_path",
 | |
| 42 | +))
 | |
| 43 | +def test_show_invalid_element_path(cli, datafiles):
 | |
| 44 | +    project = os.path.join(datafiles.dirname, datafiles.basename)
 | |
| 45 | +    result = cli.run(project=project, silent=True, args=[
 | |
| 46 | +        'show',
 | |
| 47 | +        "foo.bst"])
 | |
| 48 | + | |
| 49 | +    result.assert_main_error(ErrorDomain.LOAD, LoadErrorReason.INVALID_DATA)
 | |
| 50 | + | |
| 51 | + | |
| 39 | 52 |  @pytest.mark.datafiles(DATA_DIR)
 | 
| 40 | 53 |  @pytest.mark.parametrize("target,except_,expected", [
 | 
| 41 | 54 |      ('target.bst', 'import-bin.bst', ['import-dev.bst', 'compose-all.bst', 'target.bst']),
 | 
