feat: emit per-test JUnit XML from the clojure_test runner#105
Open
english wants to merge 1 commit into
Open
Conversation
a3f395d to
128218e
Compare
## Summary The `clojure_test` runner only reported a pass/fail exit code, so Bazel synthesised a single stub result per target. The runner now emits structured JUnit XML to `$XML_OUTPUT_FILE`, so Bazel surfaces **one result per `deftest`** with timing and failure/error detail instead of a synthesised stub. ## What changed - `testrunner.clj` hooks `clojure.test`'s `:begin-test-var` / `:end-test-var` events to build one `<testcase>` per `deftest` (grouped into one `<testsuite>` per namespace), then serialises to `$XML_OUTPUT_FILE`. - Assertion failures → `<failure>`, uncaught exceptions → `<error>`, each with message + expected/actual or stacktrace. - Namespace-load failures and fixture exceptions surface as errored testcases rather than disappearing into the exit code. - XML is hand-rolled (no new deps) so the isolated AOT bootstrap keeps working; console output is unchanged. ## Notes - `<system-out>` is deliberately omitted. The old path wrote no `$XML_OUTPUT_FILE`, so Bazel's stub generator ([`generate-xml.sh`](https://github.com/bazelbuild/bazel/blob/8.6.0/tools/test/generate-xml.sh)) embedded the full `test.log` in `<system-out>`; emitting our own XML drops that auto-embedded log. This matches Bazel's own [`AntXmlResultWriter`](https://github.com/bazelbuild/bazel/blob/8.6.0/src/java_tools/junitrunner/java/com/google/testing/junit/runner/model/AntXmlResultWriter.java) (which leaves `<system-out>` empty), and the console log is still captured in `test.log`. - New `testrunner-test` covers well-formedness, one-suite-per-namespace, count aggregation, and special-character escaping. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
clojure_testrunner only reported a pass/fail exit code, so Bazelgenerated a single stub JUnit result per target. The runner now emits structured
JUnit XML to
$XML_OUTPUT_FILE, so Bazel surfaces one result perdeftestwith timing and failure/error detail instead of a synthesised stub.
What changed
testrunner.cljhooksclojure.test's:begin-test-var/:end-test-varevents to build one
<testcase>perdeftest(grouped into one<testsuite>per namespace), then serialises to$XML_OUTPUT_FILE.<failure>, uncaught exceptions →<error>, each withmessage + expected/actual or stacktrace.
rather than disappearing into the exit code.
console output is unchanged.
In addition to producing the JUnit report, running
bazel testwith the--test_summary=detailedflag will have bazel output per-deftest results, including timing, like:Notes
<system-out>is deliberately omitted. The old path wrote no$XML_OUTPUT_FILE, so Bazel's stub generator(
generate-xml.sh)embedded the full
test.login<system-out>; emitting our own XML dropsthat auto-embedded log. This matches Bazel's own
AntXmlResultWriter(which leaves
<system-out>empty), and the console log is still captured intest.log.