Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Continue on template decode errors #3605

Merged
merged 4 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/cfnlint/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,9 @@ def _validate_filenames(self, filenames: Sequence[str | None]) -> Iterator[Match
"E0000".startswith(x) for x in self.config.ignore_checks
):
matches = [match for match in matches if match.rule.id != "E0000"]
if matches:
yield from iter(matches)
return
else:
yield from iter(matches)
return

yield from iter(matches)
continue
yield from self.validate_template(filename, template) # type: ignore[arg-type] # noqa: E501

def validate_template(
Expand Down
55 changes: 55 additions & 0 deletions test/unit/module/runner/test_run.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
"""
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
SPDX-License-Identifier: MIT-0
"""

import pytest

from cfnlint.config import ConfigMixIn
from cfnlint.runner import Runner


@pytest.mark.parametrize(
"name,config,expected_count",
[
(
"Test decode errors with multiple files",
ConfigMixIn(
cli_args=[
"--template",
"test/fixtures/templates/bad/duplicate.yaml",
"test/fixtures/templates/bad/duplicate.json",
]
),
6,
),
(
"Test decode errors with E0000 being ignored",
ConfigMixIn(
cli_args=[
"--template",
"test/fixtures/templates/bad/core/parse_invalid_map.yaml",
"--ignore-bad-template",
]
),
0,
),
(
"Test decode return E0000 errors",
ConfigMixIn(
cli_args=[
"--template",
"test/fixtures/templates/bad/core/parse_invalid_map.yaml",
]
),
1,
),
],
)
def test_run(name, config, expected_count):

runner = Runner(config)

errs = list(runner.run())

assert len(errs) == expected_count, f"{name}: {errs}"
Loading