rust/library/test/src
bors 1c6868aa21 Auto merge of #84568 - andoriyu:libtest/junit_formatter, r=yaahc
feat(libtest): Add JUnit formatter

tracking issue: https://github.com/rust-lang/rust/issues/85563

Add an alternative formatter to `libtest`. Formatter produces valid xml that later can be interpreted as JUnit report.

Caveats:

- `timestamp` is required by schema, but every viewer/parser ignores it. Attribute is not set to avoid depending on chrono;
- Running all "suits" (unit tests, doc-tests and integration tests) will produce a mess;
- I couldn't find a way to get integration test binary name, so it's just goes by "integration";

Sample output for unit tests (pretty printed by 3rd party tool):
```
<?xml version="1.0" encoding="UTF-8"?>
<testsuites>
  <testsuite name="test" package="test" id="0" errors="0" failures="0" tests="13" skipped="1">
    <testcase classname="results::tests" name="test_completed_bad" time="0"/>
    <testcase classname="results::tests" name="suite_started" time="0"/>
    <testcase classname="results::tests" name="suite_ended_ok" time="0"/>
    <testcase classname="results::tests" name="suite_ended_bad" time="0"/>
    <testcase classname="junit::tests" name="test_failed_output" time="0"/>
    <testcase classname="junit::tests" name="test_simple_output" time="0"/>
    <testcase classname="junit::tests" name="test_multiple_outputs" time="0"/>
    <testcase classname="results::tests" name="test_completed_ok" time="0"/>
    <testcase classname="results::tests" name="test_stared" time="0"/>
    <testcase classname="junit::tests" name="test_generate_xml_no_error_single_testsuite" time="0"/>
    <testcase classname="results::tests" name="test_simple_output" time="0"/>
    <testcase classname="test" name="should_panic" time="0"/>
    <system-out/>
    <system-err/>
  </testsuite>
</testsuites>
```

Sample output for integration tests (pretty printed by 3rd party tool):

```
<?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="integration" name="test_add" time="0"/>
    <system-out/>
    <system-err/>
  </testsuite>
</testsuites>
```

Sample output for Doc-tests (pretty printed by 3rd party tool):

```
<?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="src/lib.rs" name="(line 2)" time="0"/>
    <system-out/>
    <system-err/>
  </testsuite>
</testsuites>
```
2021-05-27 21:14:55 +00:00
..
formatters Better output for junit formatter 2021-04-30 17:16:09 -07:00
helpers lazily calls some fns 2021-03-27 10:20:32 +03:00
stats mv std libs to library/ 2020-07-27 19:51:13 -05:00
bench.rs move core::hint::black_box under its own feature gate 2021-04-25 11:08:12 +02:00
cli.rs feat(libtest): Add JUnit formatter 2021-04-25 15:51:50 -07:00
console.rs feat(libtest): Add JUnit formatter 2021-04-25 15:51:50 -07:00
event.rs libtest: Index tests by a unique TestId 2021-03-24 23:08:13 -07:00
lib.rs Expose Concurrent (private type in public i'face) 2021-05-14 13:28:56 +01:00
options.rs feat(libtest): Add JUnit formatter 2021-04-25 15:51:50 -07:00
stats.rs Fix some clippy issues 2020-10-01 01:34:38 -04:00
test_result.rs Remove unsafe impl Send for CompletedTest & TestResult 2021-02-19 00:00:00 +00:00
tests.rs libtest: Index tests by a unique TestId 2021-03-24 23:08:13 -07:00
time.rs Dogfood 'str_split_once()` in the std lib 2020-12-07 14:24:05 -07:00
types.rs libtest: Index tests by a unique TestId 2021-03-24 23:08:13 -07:00