-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Libtest generated junit report includes extra newline at the start. #93454
Comments
Looking back at #89235 I think the newline was added to make the output consistent with other test output formats when dumped via cargo. I think the issue here being that cargo expects the extra newlines to be generated by libtest, but it may be that we need to move that around so that libtest only outputs the test report with no extra whitespace and cargo handles padding it appropriately for a nice cohesive report. I think it's fine if we remove the newlines here but I think we will instead want to update cargo to insert the newlines, make sure that the output you can capture via redirect doesn't include those newlines, and then make sure all the other test outputs don't regress as a result, probably by updating them as well. |
I think, newlines here actually aren't necessary. In #89235 you're comparing machine-readable junit to human-readable output, and if you compare it to json - json has not extra padding. Of course, we can remove newlines here and add them in cargo, but in my opinion this adds no real value and adds some complexity, sure it looks nice without redirection, but output is supposed to be redirected, and if redirected, it will look like this:
You've added Is there some example project with doctests so i can test how it would look? |
Sounds reasonable. 👍
Oh, lovely! As for example doctests, If you wanted to setup a permanent / repeatable test the best place for that would probably be in |
"real quick" for me taking longer than expected :) I've followed this guide: https://rustc-dev-guide.rust-lang.org/getting-started.html At the
Then in my But output doesn't seem to be affected by my changes to junit formatter. Am i missing something? |
That all sounds correct. It might be that you're selecting too small of a subset of the build to properly use as an override. Does it work if you run a full build with Also, incase it helps the zulip might be a better venue for getting help debugging your issues: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs |
I managed to build and test it, and it is working as expected. Thanks for help! But, junit reporter is still can be used in very limited cases: only when there is one type of tests, becouse, when there is unit/integration and doctests, every category (and every file in tests/) produces new xml. And with current architecture i don't see a way to fix this. Luckily, using To achive the same result with libtest/cargo-test we need a way to write header at the run start, and by "run" i mean "running all tests", and to write footer after all tests are completed. |
That's unfortunate. Does the |
{ "type": "suite", "event": "started", "test_count": 1 }
{ "type": "test", "event": "started", "name": "tests::it_works" }
{ "type": "test", "name": "tests::it_works", "event": "ok" }
{ "type": "suite", "event": "ok", "passed": 1, "failed": 0, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": 0.000127229 }
{ "type": "suite", "event": "started", "test_count": 1 }
{ "type": "test", "event": "started", "name": "tests::it_works" }
{ "type": "test", "name": "tests::it_works", "event": "ok" }
{ "type": "suite", "event": "ok", "passed": 1, "failed": 0, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": 0.000227738 }
{ "type": "suite", "event": "started", "test_count": 2 }
{ "type": "test", "event": "started", "name": "tests::it_fails" }
{ "type": "test", "event": "started", "name": "tests::it_works" }
{ "type": "test", "name": "tests::it_works", "event": "ok" }
{ "type": "test", "name": "tests::it_fails", "event": "failed", "stdout": "thread 'tests::it_fails' panicked at 'assertion failed: `(left == right)`\n left: `4`,\n right: `5`', tests/test_something.rs:12:9\nnote: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n" }
{ "type": "suite", "event": "failed", "passed": 1, "failed": 1, "allowed_fail": 0, "ignored": 0, "measured": 0, "filtered_out": 0, "exec_time": 0.000585028 } And then, I think, yes, in theory we can let I will think about it. |
…r=yaahc fix: Remove extra newlines from junit output This PR fixes extra newline in junit output rust-lang#93454
…r=yaahc fix: Remove extra newlines from junit output This PR fixes extra newline in junit output rust-lang#93454
rust/library/test/src/formatters/junit.rs
Line 36 in 24ae996
Hello, is there a reason to include this newline at the start?
@yaahc i'm tagging you, looks like it was your commit.
7779eb7
I'm trying to use junit format in github actions, and with this line, generated output could not be parsed by python junitparser. Sure it could be fixed there, but i don't think of any particular reason why this newline is needed.
Also, those ending newlines isn't neccessary (but hopefully they aren't breaking anything).
Or maybe I doing something wrong here?
The text was updated successfully, but these errors were encountered: