Skip to content

Cannot benchmark a unit test, always get "running 0 tests" #399

@samthebest

Description

@samthebest

Usually I run a test like this:

cargo test name_of_test

and in the output I see:

running 1 test

where we have something like:

#[cfg(test)]
mod tests {
    #[test]
    fn name_of_test() { ...

Now with flamegraph I've tried (billions of permutations of the following arguments, with full path to the test, not full path, -- here -- there, no --, chuck in --lib in a few places, tried --unit-test-kind, etc, etc, adding tests:: like I have an AI running 24/7 trying permutations of the arguments costing $1m per day, and it hasn't found one that works 😆 ):

CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --unit-test -- name_of_test

It just doesn't actually run any tests:

running 0 tests

Sometimes I get permutations with:

Error: crate has no automatically selectable target:
Hint: try passing `--example <example>` or similar to choose a binary

If I try without trying to even specify a test, i.e.:

CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --unit-test

I get:

running 0 tests

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions