Skip to content

Handle tests that omit JUnit XML output - #21

Merged
alexeagle merged 4 commits into
8.8.0-figmafrom
codex/test-xml-missing-action-mode
Aug 19, 2026
Merged

Handle tests that omit JUnit XML output#21
alexeagle merged 4 commits into
8.8.0-figmafrom
codex/test-xml-missing-action-mode

Conversation

@alexeagle

@alexeagle alexeagle commented Aug 19, 2026

Copy link
Copy Markdown

Summary

Bazel test actions declare test.xml as an output and now have an explicit policy for runners that exit without creating it.

This change:

  • adds --experimental_test_xml_missing_behavior={legacy,fail,warn,workaround}
  • defaults to legacy, preserving silent derived XML generation
  • lets fail reject a successful test action that omitted test.xml
  • lets warn emit a warning and run the derived XML action under the distinct TestXmlGenerationFallback mnemonic
  • lets workaround supervise the test, preserve its exit status, and atomically create minimal JUnit XML only when the runner did not
  • embeds native supervisors for Linux amd64/arm64 and Darwin arm64
  • keeps test, --run_under, coverage, signal, and remote-execution command ordering intact

Why

Some test runners ignore Bazel's XML_OUTPUT_FILE contract. Bazel historically hides that by deriving XML from test.log. That makes missing runner output hard to detect and prevents controlled migration to stricter behavior.

The new policy supports three migration steps:

  1. observe missing XML with warn
  2. preserve compatibility at execution time with workaround
  3. enforce the output contract with fail

The wrapper never replaces XML written by the test. If it cannot publish XML, workaround mode fails instead of hiding the problem behind the later derived-XML action.

Relationship to split XML generation

--experimental_split_xml_generation moved fallback XML creation out of test-setup.sh into a separate spawn, fixing subtle output and signal-handling races. It had been default-on since 2019 and was removed in Bazel 9 by #26049 because split generation was considered stable; Bazel 9 always uses that path.

That fixed how Bazel creates fallback XML, but not the underlying contract violation. When a runner omits test.xml, Bazel still silently synthesizes one from test.log, so CI receives XML while the missing runner report remains invisible. This PR adds policy at that decision point: observe it, wrap it for compatibility, or fail it.

This PR targets 8.8.0-figma, where --experimental_split_xml_generation still exists and defaults to true.

Validation

  • bazel test //src/test/java/com/google/devtools/build/lib/analysis:AnalysisTests //src/test/java/com/google/devtools/build/lib/exec:ExecTests with focused test filters
  • bazel test //tools/test/ensure_xml:ensure_xml_test
  • bazel build //src:bazel
  • end-to-end //examples/shell:test in workaround mode on Darwin arm64
    • test passed
    • native ensure_xml_darwin_arm64 supervised execution
    • valid JUnit XML was created
    • no derived XML fallback spawn ran
  • bash -n tools/test/test-setup.sh

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit 45e5720. Configure here.

Comment thread tools/test/ensure_xml/BUILD
@alexeagle
alexeagle merged commit 5521b8b into 8.8.0-figma Aug 19, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants