formatter: make JUnit error testcase names unique - #2592
Merged
bendrucker merged 1 commit intoJul 24, 2026
Merged
Conversation
Contributor
Author
junitErrors used the bare diagnostic summary as the testcase name, so multiple diagnostics sharing a summary (e.g. the same error on two lines) produced duplicate <testcase> names in the same <testsuite>. Include the diagnostic range in the name, mirroring how issue testcases are named since terraform-linters#2538. Fixes terraform-linters#1608
Kunalbehbud
force-pushed
the
fix/junit-unique-error-names
branch
from
July 21, 2026 10:58
f5a20e5 to
1579ab3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1608
Problem
#2538 made issue testcase names unique by including the range, but the error testcases appended after them still use the bare diagnostic summary. Multiple diagnostics sharing a summary — e.g. the same
Unsupported argumenterror on two different lines — still produce duplicate<testcase>names inside the same<testsuite>, which JUnit consumers key on.This is exactly the gap called out in the review of #2522:
and:
Change
Include the diagnostic range in the error testcase name, mirroring the issue-testcase naming from #2538 (
<summary> <range>, via the existing nil-safediagRange). Theapplication_errorsingleton case is untouched.One edge worth noting: two subject-less diagnostics with an identical summary would still collide (both synthesize the empty range
:0,0-0). That mirrors the pre-#2538 state for issues and seems acceptable for a case that can't point at a location — happy to add a positional suffix there if you'd prefer.Tests
<testcase>names.