mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Rollup merge of #89235 - yaahc:junit-formatting, r=kennytm
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) <?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><font color="#A1B56C"><b> Doc-tests</b></font> 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> </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) <?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> <font color="#A1B56C"><b> Doc-tests</b></font> 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> </pre>
This commit is contained in:
commit
e601554dc0
@ -29,7 +29,8 @@ impl<T: Write> JunitFormatter<T> {
|
|||||||
impl<T: Write> OutputFormatter for JunitFormatter<T> {
|
impl<T: Write> OutputFormatter for JunitFormatter<T> {
|
||||||
fn write_run_start(&mut self, _test_count: usize) -> io::Result<()> {
|
fn write_run_start(&mut self, _test_count: usize) -> io::Result<()> {
|
||||||
// We write xml header on run start
|
// We write xml header on run start
|
||||||
self.write_message(&"<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
|
self.out.write_all(b"\n")?;
|
||||||
|
self.write_message("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write_test_start(&mut self, _desc: &TestDesc) -> io::Result<()> {
|
fn write_test_start(&mut self, _desc: &TestDesc) -> io::Result<()> {
|
||||||
@ -133,6 +134,8 @@ impl<T: Write> OutputFormatter for JunitFormatter<T> {
|
|||||||
self.write_message("</testsuite>")?;
|
self.write_message("</testsuite>")?;
|
||||||
self.write_message("</testsuites>")?;
|
self.write_message("</testsuites>")?;
|
||||||
|
|
||||||
|
self.out.write_all(b"\n\n")?;
|
||||||
|
|
||||||
Ok(state.failed == 0)
|
Ok(state.failed == 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user