Skip to content

Fix JUnit HTML reports collapsing whitespace in failure messages#3732

Open
Copilot wants to merge 1 commit intomasterfrom
copilot/fix-junit-test-reports
Open

Fix JUnit HTML reports collapsing whitespace in failure messages#3732
Copilot wants to merge 1 commit intomasterfrom
copilot/fix-junit-test-reports

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

Browsers collapse consecutive whitespace by default, making failure messages with significant spacing (e.g. String s = (String)o;String s = (String)o;) unreadable in generated JUnit HTML reports.

Changes

JUNIT.XSL

  • Add code { white-space: pre-wrap; } CSS rule to preserve spaces and newlines inside <code> blocks
  • Wrap @message output in <code> so the failure message inherits the same rule
<!-- Before -->
<xsl:value-of select="@message"/>

<!-- After -->
<code><xsl:value-of select="@message"/></code>

verify/ — self-contained verification helper (no build required)

  • sample-results.xml: JUnit XML with intentional whitespace in failure messages
  • verify.sh: transforms the sample XML with JUNIT.XSL and opens the result in a browser; supports WSL (explorer.exe), macOS (open), and Linux (xdg-open); requires xsltproc (sudo apt-get install xsltproc) or python3 + lxml
cd products/eclipse-junit-tests/src/main/scripts/verify
./verify.sh

Verification output showing whitespace preserved


💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.

Copilot AI linked an issue Mar 27, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Fix JUnit test reports not preserving empty spaces Fix JUnit HTML reports collapsing whitespace in failure messages Mar 27, 2026
Copilot AI requested a review from fedejeanne March 27, 2026 20:31
@fedejeanne
Copy link
Copy Markdown
Member

@copilot how do I check if this PR does what it is supposed to do?

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 27, 2026

@copilot how do I check if this PR does what it is supposed to do?

To verify this PR locally:

  1. Build a JUnit XML result file (or use the one attached to the original issue) and run the JUNIT.XSL transform against it with Ant or any XSLT processor. The simplest way is to run the existing test build — the HTML reports are generated in testresults/html/.

  2. Alternatively, you can download the attached test zip from the original issue, extract the XML file from it, and apply JUNIT.XSL to it.

  3. Open the resulting HTML file in a browser and look at the "Type" column for the testFormatAll01 failure. With this fix, spaces are preserved — you should see String s = (String)o; (4 spaces) instead of String s = (String)o; (1 space), and the stack trace should show proper indentation.

Before (spaces collapsed):
Before

After (spaces preserved):
After

Notice String s = (String)o; with 4 spaces in the message line, and proper indentation in the stack trace.

@fedejeanne fedejeanne force-pushed the copilot/fix-junit-test-reports branch from faeb12d to be9ce23 Compare March 27, 2026 21:56
@fedejeanne fedejeanne marked this pull request as ready for review March 27, 2026 21:56
Copy link
Copy Markdown
Member

@fedejeanne fedejeanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it locally, works as expected.

If there are no objections, I will merge this next week.

Copy link
Copy Markdown
Member

@HannesWell HannesWell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it locally, works as expected.

How did you test it exactly?

Although it's not exactly related to this task, are you aware of the instructions how to test the build website locally?
https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/tree/master/sites/eclipse
In this case it doesn't help since the test-data download script doesn't download test results.

@fedejeanne fedejeanne force-pushed the copilot/fix-junit-test-reports branch 2 times, most recently from ed8fe9a to 680f096 Compare March 30, 2026 07:29
- Add `white-space: pre-wrap` CSS rule for `code` elements so spaces and
  newlines are preserved in browser rendering
- Wrap @message output in a `<code>` element so the failure message text
  also benefits from the whitespace preservation CSS rule

Fixes: #3723

Agent-Logs-Url: https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/sessions/70ecfbb4-6cee-4f8f-a49b-c8496722fff2

Co-authored-by: Federico Jeanne <Federico.Jeanne@vector.com>
@fedejeanne fedejeanne force-pushed the copilot/fix-junit-test-reports branch from 680f096 to 3d79801 Compare March 30, 2026 07:30
Copy link
Copy Markdown
Member

@fedejeanne fedejeanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you test it exactly?

@HannesWell I used a script generated by copilot in WSL. I put it in my own branch for you to test too, if you want:

@laeubi
Copy link
Copy Markdown
Contributor

laeubi commented Mar 30, 2026

@fedejeanne please keep in mind this when working with copilot on platform repos:

https://github.com/eclipse-platform/.github/blob/main/CONTRIBUTING.md#using-github-copilot-agent

this prevents a lot of mail-traffic when some iterations are needed and you can later create a PR against the base easily instead of having the branches live in the main repository.

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.

JUnit test reports don't preserve empty spaces

4 participants