Skip to content

Commit

Permalink
Add location to duplicate spec errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Senier committed Mar 10, 2021
1 parent 7febcf7 commit 4eeb435
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
11 changes: 8 additions & 3 deletions rflx/specification/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1244,14 +1244,19 @@ def __convert_unit(
and filename != self.__specifications[packagefile].filename
):
error.append(
f'duplicate specification "{filename}"',
"duplicate specification",
Subsystem.PARSER,
Severity.ERROR,
node_location(spec.f_package_declaration.f_identifier, filename),
)
error.append(
f'previous specification "{self.__specifications[packagefile].filename}"',
"previous specification",
Subsystem.PARSER,
Severity.ERROR,
Severity.INFO,
node_location(
self.__specifications[packagefile].spec.f_package_declaration.f_identifier,
self.__specifications[packagefile].filename,
),
)
self.__specifications[packagefile] = SpecificationNode(filename, spec, withed_files)

Expand Down
10 changes: 6 additions & 4 deletions tests/unit/specification/parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2429,8 +2429,9 @@ def test_parse_error_duplicate_spec_file_file() -> None:
with pytest.raises(
RecordFluxError,
match=(
'^parser: error: duplicate specification "tests/data/specs/subdir/message_type.rflx"\n'
'parser: error: previous specification "tests/data/specs/message_type.rflx"$'
"^tests/data/specs/subdir/message_type.rflx:1:9: parser: error: duplicate"
" specification\n"
"tests/data/specs/message_type.rflx:1:9: parser: info: previous specification$"
),
):
p.parse(SPEC_DIR / "subdir/message_type.rflx")
Expand All @@ -2452,8 +2453,9 @@ def test_parse_error_duplicate_spec_stdin_file() -> None:
with pytest.raises(
RecordFluxError,
match=(
'^parser: error: duplicate specification "tests/data/specs/subdir/message_type.rflx"\n'
'parser: error: previous specification "<stdin>"$'
"^tests/data/specs/subdir/message_type.rflx:1:9: parser: error: duplicate"
" specification\n"
"<stdin>:2:17: parser: info: previous specification$"
),
):
p.parse(SPEC_DIR / "subdir/message_type.rflx")

0 comments on commit 4eeb435

Please sign in to comment.