CARGO-SUBUNIT(1)

πŸ“¦ version 0.1.3, in ubuntu stonking

πŸ’– CARGO-SUBUNIT πŸ’–

okay bestie, so this is cargo-subunit β€” a manual page from the User Commands section, and honestly? it's giving ✨test infrastructure but make it cute✨. stay with me.


🌸 NAME 🌸

cargo-subunit β€” run Rust tests and spit the results out in subunit format. that's it, that's the whole vibe.


πŸ¦‹ SYNOPSIS πŸ¦‹

cargo subunit [--list] [--load-list FILE] [CARGO_ARGS...]  [-- TEST_ARGS...]

like literally just cargo subunit and then whatever else you want to throw at it. she's flexible πŸ’…


πŸŽ€ DESCRIPTION πŸŽ€

cargo-subunit is a Cargo extension that runs your Rust tests and outputs the results in subunit v2 format. why do you care? because this is what lets your test results talk to subunit tools and test runners like testrepository(1). it's a whole ecosystem and we're integrating with it, no cap.

the way it works: the tool uses cargo test's unstable JSON output format to capture test events, and then converts those into subunit v2 format. so basically it's a lil translator 🧚 that lets all these subunit-compatible tools consume your test results for analysis, reporting, and test management. periodt.

heads up: that's cargo test's unstable JSON output it's leaning on β€” that's what the page says, so don't come for me.

✨ OPTIONS ✨

  • --list β€” list every available test without running them. each test gets output as a subunit "exists" event with its fully-qualified name (like module::submodule::test_name). window shopping, but for tests πŸ‘€
  • --load-list FILE β€” load test names from FILE (one test name per line) and run only those tests. empty lines? ignored. queen of efficiency.
  • --help β€” display help info and dip out.
  • --version β€” display version info and dip out.

🌈 ARGUMENTS 🌈

  • CARGO_ARGS β€” args you pass along to cargo test, like package selection flags (--package, --workspace), feature flags (--features, --no-default-features), or compilation options (--release). all your faves πŸ’–
  • TEST_ARGS β€” args passed to the test binary, and these must be preceded by --. common ones include --nocapture (show stdout/stderr, we love a chatty test), --test-threads (number of parallel test threads), and test name filters.

πŸ’… OUTPUT FORMAT πŸ’…

cargo-subunit writes subunit v2 binary format to stdout. you can redirect that to a file or pipe it into subunit analysis tools. chef's kiss πŸ“

for --list mode, each test generates an "exists" event with the test ID.

for actually running tests, here's the event lineup:

  • an "inprogress" event when the test starts
  • a "success", "fail", or "skip" event when it's complete
  • for failures, stdout/stderr get attached as file content

⭐ EXAMPLES ⭐

list all the available tests:

cargo subunit --list

run everything and get subunit output:

cargo subunit > results.subunit

run specific tests matching a pattern:

cargo subunit test_name
cargo subunit module::

run tests from a file:

echo module::test_one > tests.txt
echo module::test_two >> tests.txt
cargo subunit --load-list tests.txt

pass extra cargo test args:

cargo subunit -- --nocapture
cargo subunit -- --test-threads=1

run tests in release mode:

cargo subunit --release

🧚 INTEGRATION WITH TESTREPOSITORY 🧚

cargo-subunit plays nice with testrepository(1) for tracking test history and running tests efficiently. it's a situationship that actually works 🫢

make a .testr.conf file in your project root:

[DEFAULT]
test_command=cargo subunit $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE
test_list_option=--list

then use the testrepository commands:

  • testr run β€” run all tests and record results
  • testr run --failing β€” run only the failed tests from the last run
  • testr last β€” list test runs
  • testr last --subunit | subunit-stats β€” show results from the last run

πŸ”₯ EXIT STATUS πŸ”₯

cargo-subunit exits with the same status code as the underlying cargo test command. typically:

  • 0 β€” all tests passed successfully πŸŽ‰
  • 101 β€” one or more tests failed 😭
  • other β€” compilation or other error occurred πŸ’€

πŸ‘‘ REQUIREMENTS πŸ‘‘

  • Rust 2021 edition or later
  • the subunit crate for protocol serialization

🌸 SEE ALSO 🌸

cargo(1), cargo-test(1), testrepository(1), subunit-stats(1)

Subunit protocol specification: https://github.com/testing-cabal/subunit

Project repository: https://github.com/jelmer/cargo-subunit


πŸ’œ AUTHOR πŸ’œ

Written by Jelmer VernooΔ³ <jelmer@jelmer.uk>


πŸ’– LICENSE πŸ’–

Apache-2.0


and that's the whole page bestie, fr fr. this manual documents cargo-subunit 0.1.1, dated 2025-11-12, and it lives in the CARGO-SUBUNIT(1) section of the manual. go forth and slay your test suite πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from