Skip to content

CompilationTestHelper: group expectations and reported diagnostics per failing line - #6192

Open
reginaldalfret wants to merge 1 commit into
google:masterfrom
reginaldalfret:oss-fix/error-prone-test-helper-message
Open

reginaldalfret wants to merge 1 commit into
google:masterfrom
reginaldalfret:oss-fix/error-prone-test-helper-message

Conversation

@reginaldalfret

@reginaldalfret reginaldalfret commented Oct 11, 2026 •

Copy link
Copy Markdown

Summary

When a CompilationTestHelper test fails, expectations and diagnostics were reported in disconnected sections: mismatches listed line numbers and expectation strings, followed by All errors: which printed every diagnostic emitted during compilation (including passing lines) in a single dump. When a diagnostic was missing on a line, that line's source code did not appear anywhere in the failure message.

This change:

  1. Groups what was expected and what was reported per failing line.
  2. For missing diagnostics on line N, prints the expectation followed by /file.java:N: no diagnostic was reported on this line and the source line indented by 4 spaces.
  3. For unexpected or text-mismatched diagnostics on line N, prints the expectation followed by the diagnostics reported on line N.
  4. Omits diagnostics on passing lines from the failure output.
  5. Emits any unattached diagnostics (or diagnostics on unmarked lines without line positions) in an optional closing Other diagnostics: block (omitted when empty).

Fixes #6145.

Testing

  • Updated existing CompilationTestHelperTest assertions to reflect grouped failure reporting.
  • Added ourKindsOfLineGroupingExpectationAndReportedDiagnostics verifying passing line omission, missing diagnostic source printing, mismatched text reporting, and single reporting of unexpected lines.
  • Ran all tests in est_helpers and check_api cleanly via Maven.

…r failing line

When a line fails its expectation, print the expectation together with
the diagnostics reported on that line, or with the source code of the line
when no diagnostic was emitted. Diagnostics on passing lines are omitted,
and unattached diagnostics are listed in an 'Other diagnostics:' block.

Fixes google#6145.

Signed-off-by: reginaldalfret <reginaldalfret@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CompilationTestHelper: what a failing line expected and what it got are printed in different parts of the message

1 participant