Skip to content
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

make junit output more consistent with default format #89235

Merged
merged 2 commits into from
Sep 29, 2021

Conversation

yaahc
Copy link
Member

@yaahc yaahc commented Sep 24, 2021

The default format of libtest includes new-lines between each section to ensure the label output from cargo is on it's own line

 cargo test
   Compiling test-test v0.1.0 (/home/jlusby/tmp/test-test)
    Finished test [unoptimized   debuginfo] target(s) in 0.59s
     Running unittests (target/debug/deps/test_test-639f369234319c09)

running 1 test
test tests::it_works ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests test-test

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s


But when the junit outputter was added to libtest these newlines were omitted, resulting in some "fun" output when run via cargo.

Note the Doc-tests text at the end of the first line of xml.

 cargo test -- -Zunstable-options --format junit
    Finished test [unoptimized   debuginfo] target(s) in 0.00s
     Running unittests (target/debug/deps/test_test-639f369234319c09)
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="0" tests="1" skipped="0" ><testcase classname="tests" name="it_works" time="0"/><system-out/><system-err/></testsuite></testsuites>   Doc-tests test-test
<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="0" tests="0" skipped="0" ><system-out/><system-err/></testsuite></testsuites>

After this PR the junit output includes the same style of newlines as the pretty format

 cargo test -- -Zunstable-options --format junit
   Compiling test-test v0.1.0 (/home/jlusby/tmp/test-test)
    Finished test [unoptimized   debuginfo] target(s) in 0.39s
     Running unittests (target/debug/deps/test_test-42c2320bb9450c69)

<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="0" tests="1" skipped="0" ><testcase classname="tests" name="it_works" time="0"/><system-out/><system-err/></testsuite></testsuites>

   Doc-tests test-test

<?xml version="1.0" encoding="UTF-8"?><testsuites><testsuite name="test" package="test" id="0" errors="0" failures="0" tests="0" skipped="0" ><system-out/><system-err/></testsuite></testsuites>


@rust-highfive
Copy link
Collaborator

r? @Mark-Simulacrum

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 24, 2021
@yaahc yaahc added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Sep 24, 2021
@yaahc
Copy link
Member Author

yaahc commented Sep 24, 2021

r? rust-lang/libs

@yaahc
Copy link
Member Author

yaahc commented Sep 24, 2021

@andoriyu since you authored the original junit PR I wanted to double check with you that the newlines I'm adding don't mess with any of your original design goals. I know there's the assert against newlines in write_message and I assumed that was to prevent newlines in the middle of the xml output. I figured that it would however be fine to include extra newlines before and after.

@andoriyu
Copy link
Contributor

@andoriyu since you authored the original junit PR I wanted to double check with you that the newlines I'm adding don't mess with any of your original design goals. I know there's the assert against newlines in write_message and I assumed that was to prevent newlines in the middle of the xml output. I figured that it would however be fine to include extra newlines before and after.

I think adding newlines is fine.

Copy link
Member

@kennytm kennytm left a comment

Choose a reason for hiding this comment

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

r=me but i think we could use b"…" instead of "…".aṡ_bytes().

library/test/src/formatters/junit.rs Outdated Show resolved Hide resolved
library/test/src/formatters/junit.rs Outdated Show resolved Hide resolved
@kennytm
Copy link
Member

kennytm commented Sep 27, 2021

@bors r rollup

@bors
Copy link
Contributor

bors commented Sep 27, 2021

📌 Commit 0911069 has been approved by kennytm

@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 Sep 27, 2021
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Sep 28, 2021
make junit output more consistent with default format

The default format of libtest includes new-lines between each section to ensure the label output from cargo is on it's own line

<pre><font color="#A1B56C"><b>❯</b></font> <font color="#A1B56C">cargo</font><font color="#D8D8D8"> </font><font color="#A1B56C">test</font>
<font color="#A1B56C"><b>   Compiling</b></font> test-test v0.1.0 (/home/jlusby/tmp/test-test)
<font color="#A1B56C"><b>    Finished</b></font> test [unoptimized   debuginfo] target(s) in 0.59s
<font color="#A1B56C"><b>     Running</b></font> unittests (target/debug/deps/test_test-639f369234319c09)

running 1 test
test tests::it_works ... <font color="#A1B56C">ok</font>

test result: <font color="#A1B56C">ok</font>. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

<font color="#A1B56C"><b>   Doc-tests</b></font> test-test

running 0 tests

test result: <font color="#A1B56C">ok</font>. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

</pre>

But when the junit outputter was added to libtest these newlines were omitted, resulting in some "fun" output when run via cargo.

Note the `Doc-tests` text at the end of the first line of xml.

<pre><font color="#A1B56C"><b>❯</b></font> <font color="#A1B56C">cargo</font><font color="#D8D8D8"> </font><font color="#A1B56C">test</font><font color="#D8D8D8"> </font><font color="#A1B56C">--</font><font color="#D8D8D8"> </font><font color="#A1B56C">-Zunstable-options</font><font color="#D8D8D8"> </font><font color="#A1B56C">--format</font><font color="#D8D8D8"> </font><font color="#A1B56C">junit</font>
<font color="#A1B56C"><b>    Finished</b></font> test [unoptimized   debuginfo] target(s) in 0.00s
<font color="#A1B56C"><b>     Running</b></font> unittests (target/debug/deps/test_test-639f369234319c09)
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;testsuites&gt;&lt;testsuite name=&quot;test&quot; package=&quot;test&quot; id=&quot;0&quot; errors=&quot;0&quot; failures=&quot;0&quot; tests=&quot;1&quot; skipped=&quot;0&quot; &gt;&lt;testcase classname=&quot;tests&quot; name=&quot;it_works&quot; time=&quot;0&quot;/&gt;&lt;system-out/&gt;&lt;system-err/&gt;&lt;/testsuite&gt;&lt;/testsuites&gt;<font color="#A1B56C"><b>   Doc-tests</b></font> test-test
&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;testsuites&gt;&lt;testsuite name=&quot;test&quot; package=&quot;test&quot; id=&quot;0&quot; errors=&quot;0&quot; failures=&quot;0&quot; tests=&quot;0&quot; skipped=&quot;0&quot; &gt;&lt;system-out/&gt;&lt;system-err/&gt;&lt;/testsuite&gt;&lt;/testsuites&gt;

</pre>

After this PR the junit output includes the same style of newlines as the pretty format

<pre><font color="#A1B56C"><b>❯</b></font> <font color="#A1B56C">cargo</font><font color="#D8D8D8"> </font><font color="#A1B56C">test</font><font color="#D8D8D8"> </font><font color="#A1B56C">--</font><font color="#D8D8D8"> </font><font color="#A1B56C">-Zunstable-options</font><font color="#D8D8D8"> </font><font color="#A1B56C">--format</font><font color="#D8D8D8"> </font><font color="#A1B56C">junit</font>
<font color="#A1B56C"><b>   Compiling</b></font> test-test v0.1.0 (/home/jlusby/tmp/test-test)
<font color="#A1B56C"><b>    Finished</b></font> test [unoptimized   debuginfo] target(s) in 0.39s
<font color="#A1B56C"><b>     Running</b></font> unittests (target/debug/deps/test_test-42c2320bb9450c69)

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;testsuites&gt;&lt;testsuite name=&quot;test&quot; package=&quot;test&quot; id=&quot;0&quot; errors=&quot;0&quot; failures=&quot;0&quot; tests=&quot;1&quot; skipped=&quot;0&quot; &gt;&lt;testcase classname=&quot;tests&quot; name=&quot;it_works&quot; time=&quot;0&quot;/&gt;&lt;system-out/&gt;&lt;system-err/&gt;&lt;/testsuite&gt;&lt;/testsuites&gt;

<font color="#A1B56C"><b>   Doc-tests</b></font> test-test

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&lt;testsuites&gt;&lt;testsuite name=&quot;test&quot; package=&quot;test&quot; id=&quot;0&quot; errors=&quot;0&quot; failures=&quot;0&quot; tests=&quot;0&quot; skipped=&quot;0&quot; &gt;&lt;system-out/&gt;&lt;system-err/&gt;&lt;/testsuite&gt;&lt;/testsuites&gt;

</pre>
This was referenced Sep 28, 2021
bors added a commit to rust-lang-ci/rust that referenced this pull request Sep 29, 2021
…laumeGomez

Rollup of 8 pull requests

Successful merges:

 - rust-lang#87260 (Libgccjit codegen)
 - rust-lang#89212 (x.py: run `rustup toolchain link` in setup)
 - rust-lang#89233 (Hide `<...> defined here` note if the source is not available)
 - rust-lang#89235 (make junit output more consistent with default format)
 - rust-lang#89255 (Fix incorrect disambiguation suggestion for associated items)
 - rust-lang#89276 (Fix the population of the `union.impls` field)
 - rust-lang#89283 (Add regression test for issue rust-lang#83564)
 - rust-lang#89318 (rustc_session: Remove lint store from `Session`)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit e601554 into rust-lang:master Sep 29, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 29, 2021
@yaahc yaahc deleted the junit-formatting branch September 29, 2021 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants