rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

Supporting junit XML report in rust_test

Open jgao54 opened this issue 3 years ago • 7 comments

Currently rust_test does not support generating junit xml report out-of-the-box.

To support this for all rust test target, a workaround is with the --run_under flag and a script that writes the xml report from stdout to $XML_OUTPUT_FILE:

#!/bin/bash
$@ -Zunstable-options --format=junit --report-time | tee $XML_OUTPUT_FILE

The main downside is having to declare the script as a data dependency for every rust test target.

It would be nice to have built-in support for this in rust_test as an option, would it be sensible to add this to the rust test launcher?

jgao54 avatar Apr 28 '22 19:04 jgao54

Discovered a previous related discussion here. Is this feature still in the roadmap?

jgao54 avatar Apr 28 '22 19:04 jgao54

The test launcher was actually deleted https://github.com/bazelbuild/rules_rust/issues/1069

But I think it'd be great if rust_test supported junit xml reporting.

UebelAndre avatar Apr 28 '22 20:04 UebelAndre

+ for support for rust_doc_test as well!

jgao54 avatar May 04 '22 20:05 jgao54

If anyone's got context on this, any PRs for this would be welcomed! 😄

UebelAndre avatar May 05 '22 15:05 UebelAndre

Note that having a test runner again would potentially help support code coverage as well. Although I'm sure there are downsides

keith avatar May 05 '22 15:05 keith

I think my only hesitation to adding a test runner again is breaking the ability to use --run_under for launching debuggers. I'm wondering if this might be something worth opening an upstream feature request for to maybe allow starlark rules to provide a process wrapper that can do some orchestration before running tests but not changing semantics about what binary will be start when a test is run. Does that sound reasonable? Is there a better approach?

ps: https://github.com/bazelbuild/rules_rust/issues/690 is I think related to the topic of process wrappers in my comment here.

UebelAndre avatar May 07 '22 16:05 UebelAndre

What orchestration are you thinking for this case?

I wonder if another approach would be to provide some library that could do this generation instead? I don't know rust very well but in apple land there is some infra for being able to observe test results in code, so that can actually be used in process to do this.

keith avatar May 07 '22 17:05 keith

There's an unstable JUnit formatter built in to libtest. Tracking issue: https://github.com/rust-lang/rust/issues/85563

jfirebaugh avatar Dec 21 '22 03:12 jfirebaugh