Fix trailing newline in JUnit formatter by ilammy · Pull Request #149437 · rust-lang/rust (original) (raw)

@ilammy

write_message() expects messages to contain no newlines.

Fixes #149436

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

T-libs

Relevant to the library team, which will review and decide on the PR/issue.

labels

Nov 29, 2025

@rustbot

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@chenyukang

emm, seems there is no unit tests for all the formatters (not the issue for this PR).

@Mark-Simulacrum

There are some tests in tests/run-make/libtest-junit, can you update that to make sure this stays fixed?

@ilammy

Expect the entire input to be a single XML document, instead of reading it line by line. This detects trailing junk better.

@ilammy

Copied validate_junit.py from libtest-junit.

JUnit format works well in edition 2021, but is currently broken in edition 2024 by the mergeable doctest report.

@ilammy

Fix the panic in write_message() which expects messages to contain no embedded newlines. We still want a trailing newline at the end of the file though, so write it in different manner.

Doctest runner no longer panics, but the output is kinda broken when compile_fail doctests are present. This is because they are not mergeable.

@ilammy

Added some tests to show how it works in edition 2021, fails in edition 2024, and how it's fixed by this PR.

However, while doing that I found a case that breaks JUnit output in edition 2024. Mergeable doctests will need a bit more work to fix that (should I file a separate issue for this?), but otherwise --format=junit is at least usable in some cases now.

@rustbot ready

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Dec 13, 2025

@ilammy ilammy changed the titleRemove unnecessary newline in JUnit formatter Fix trailing newline in JUnit formatter

Dec 13, 2025

@Mark-Simulacrum

Feel free to cut a separate issue. @bors r+

@bors

📌 Commit 069cf9d has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

and removed S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

labels

Dec 13, 2025

ChrisDenton added a commit to ChrisDenton/rust that referenced this pull request

Dec 14, 2025

@ChrisDenton

Fix trailing newline in JUnit formatter

write_message() expects messages to contain no newlines.

Fixes rust-lang#149436

ChrisDenton added a commit to ChrisDenton/rust that referenced this pull request

Dec 14, 2025

@ChrisDenton

Fix trailing newline in JUnit formatter

write_message() expects messages to contain no newlines.

Fixes rust-lang#149436

bors added a commit that referenced this pull request

Dec 14, 2025

@bors

Rollup of 8 pull requests

Successful merges:

r? @ghost @rustbot modify labels: rollup

@ChrisDenton

@bors bors added S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

and removed S-waiting-on-bors

Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

labels

Dec 14, 2025

@ilammy

Whoops. I should have caught onto that when my ./x test passed only with --stage 2. For some reason I thought the big pipeline handles it implicitly. Turns out, rustdoc is a bit special in that stage 1 builds (for some reason I don't fully understand) use stage 0's libtest, so any fix there are not propagated yet. Stage 2 is good though.

I'll go add ignore-stage1 on the new test. I dunno how many existing ones technically need it as well.

@ilammy

stage1's rustdoc is using stage0's libtest which does not have a fix from 069cf9d, making the test run fail. Ensure that this test is executed with everything recompiled in stage2.

@ilammy

@rustbot rustbot added S-waiting-on-review

Status: Awaiting review from the assignee but also interested parties.

and removed S-waiting-on-author

Status: This is awaiting some action (such as code changes or more information) from the author.

labels

Dec 16, 2025