CARGO-SUBUNIT(1)
π 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 (likemodule::submodule::test_name). window shopping, but for tests π--load-list FILEβ load test names fromFILE(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 tocargo 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 resultstestr run --failingβ run only the failed tests from the last runtestr lastβ list test runstestr 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
- ubuntu stonking: cargo-subunit 0.1.3-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms