Skip to content

Fix rust_test does not emit junit XML to bazel XML_OUTPUT_FILE#4084

Open
peakschris wants to merge 2 commits into
bazelbuild:mainfrom
peakschris:cb_junit_wrapper
Open

Fix rust_test does not emit junit XML to bazel XML_OUTPUT_FILE#4084
peakschris wants to merge 2 commits into
bazelbuild:mainfrom
peakschris:cb_junit_wrapper

Conversation

@peakschris

Copy link
Copy Markdown

Add JUnit XML test reporting to rust_test rules. When bazel test runs a Rust test, the wrapper parses libtest output and writes JUnit XML to $XML_OUTPUT_FILE for CI integration (Jenkins, GitHub Actions, etc.). Zero overhead on bazel run - the wrapper execs the test binary directly when $XML_OUTPUT_FILE is unset. Opt out per-target with junit = False.

Fixes #1303

Related: #3948, #3490

Changes

  • rust/private/rust.bzl: Add junit attribute (default True) and _junit_runner to rust_test. When enabled, symlink the runner as the executable and set RUST_TEST_BIN pointing to the real test binary via rlocation.
  • util/junit_runner/: New Rust binary that wraps test execution, parses libtest stdout, and writes JUnit XML.
  • util/collect_coverage/collect_coverage.rs: When the junit wrapper is active, resolve the instrumented binary from RUST_TEST_BIN instead of TEST_BINARY. Also use COVERAGE_OUTPUT_FILE when set.

Test plan

  • //util/junit_runner:junit_runner_test - 14 unit tests for parsing and XML generation
  • //test/junit:junit_test - end-to-end: wrapper runs test successfully
  • //test/junit:no_junit_test - opt-out with junit = False
  • bazel test //... - no regressions (1 pre-existing failure in remap_path_prefix on Windows, unrelated)

@google-cla

google-cla Bot commented Jun 12, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Supporting junit XML report in rust_test

1 participant