Cargo test should fail if the specified test to run isn't found

Currently, if the test passed to cargo test (as: cargo test my_module::tests::my_test) does not exist, the command raises no warning about not finding the test, and it writes test result: ok..

This has led me to think that tests I wrote were passing, when in reality they weren't, I just had misnamed them when invoking the command.

The command does result with 0 passed, but I think that this is too small and not prominent enough to notice the possible mistake.

5 Likes

Our issue for this is GitHub · Where software is built.

There are two components here: the test runner (cargo test) and the test harness (libtest). libtest can't error because it doesn't know about any other test binaries being run. cargo test can't error because it knows nothing about libtest's output.

T-testing-devex's plan is to stabilize json output from libtest and shift the responsibility for reporting from libtest to cargo test. At that point, cargo can then detect overly restrictive filters and do something about it. Whether thats a warning or an error is unclear but the issue is likely the best place for figure that out and the answer isn't pressing as this will take time to implement.

I have a 2025h1 project goal to create a proposal for the json output and i want to vet that proposal by prototyping the cargo test integration. For this to fully work, we'll need to decide how to let custom test harnesses opt-in to this new protocol and decide what to do when not all test harnesses opt-in.

7 Likes

Thanks for the response!

1 Like