Skip to content
Closed
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
6 changes: 3 additions & 3 deletions nac_validate/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,9 @@ def validate_semantics(self, input_paths: list[Path]) -> None:

if len(results) > 0:
for id, paths in results.items():
msg = (
f"Semantic error, rule {id}: {self.rules[id].description} ({paths})"
)
header = f"Semantic error, rule {id}: {self.rules[id].description}:"
items = "\n".join(f" - {path}" for path in paths)
msg = f"{header}\n{items}"
logger.error(msg)
semantic_errors.append(msg)

Expand Down
19 changes: 19 additions & 0 deletions tests/integration/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,3 +225,22 @@ def test_merge(tmpdir: Path) -> None:
)
assert result.exit_code == 0
assert filecmp.cmp(output_path, result_path, shallow=False)


def test_semantic_error_output_format() -> None:
"""Test that semantic errors are formatted as a human-readable bulleted list."""
runner = CliRunner()
input_path = "tests/integration/fixtures/data_semantic_error/"
rules_path = "tests/integration/fixtures/rules/"
result = runner.invoke(
nac_validate.cli.main.app,
["-r", rules_path, "-v", "ERROR", input_path],
)
assert result.exit_code == 1
# Verify bulleted list format with 4-space indent
assert " - " in result.output
# Verify header ends with colon (not parentheses with list)
assert "Semantic error, rule 101:" in result.output
# Verify no Python list representation in output
assert '["' not in result.output
assert "']" not in result.output