I have a test I can run as:
cargo test tests::my_test -- --nocapture
I am trying to profile it without any luck, the docs claim that you can use one of the following:
# Profile unit tests.
# Note that a separating `--` is necessary if `--unit-test` is the last flag.
cargo flamegraph --unit-test -- test::in::package::with::single::crate
cargo flamegraph --unit-test crate_name -- test::in::package::with::multiple:crate
cargo flamegraph --unit-test --dev test::may::omit::separator::if::unit::test::flag::not::last::flag
# Profile integration tests.
cargo flamegraph --test test_name
I have tried them all:
cargo flamegraph --unit-test -- test::mytest
Error: crate has no automatically selectable target:
cargo flamegraph --unit-test my_crate -- test::mytest
error: unexpected argument 'tests::mytest' found
Usage: cargo flamegraph [OPTIONS] [-- <TRAILING_ARGUMENTS>...]
For more information, try '--help'.
cargo flamegraph --test tests::mytest -- --nocapture
error: no test target named `tests::mytest`.
Error: cargo build failed
The documentation is doing a very poor job of conveying what you are actually meant to do.
I ran into this same problem and after updating from
flamegraph v0.5.1
toflamegraph v0.6.4
it worked as expected.In my project (which has multiple bin and lib crates) the magic invocation was: