You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running cargo build --benches, one might expect to only build the bench targets.
This is also the case for cargo bench command.
When building the
Steps
Create a hello world crate with some basic tests
Add a basic bench
Add a compilation error in a test
Run cargo build --benches, see compilation error
Possible Solution(s)
I have not deep dived into the cargo code, but bench targets should not build the test target, especially since benches are generally built in a release profile, it kind of makes no sense to build the targets in the release profile as well.
Notes
Sorry if this makes no sense or if it's a duplicate.
If instructions on how to reproduce are not clear enough I can provide a simple repository!
Thanks for the report! I believe this is somewhat expected behavior (in some ways similar to #6454). Building benchmarks also sets cfg(test) and that is what #[test] annotated functions use to determine if they are compiled or not. I don't know what @rust-lang/testing-devex thinks, I'm not aware of any intentions to adding a separate cfg just for benchmarks (and would be difficult to removing cfg(test) without an edition).
Problem
Hello,
When running
cargo build --benches
, one might expect to only build the bench targets.This is also the case for
cargo bench
command.When building the
Steps
cargo build --benches
, see compilation errorPossible Solution(s)
I have not deep dived into the cargo code, but bench targets should not build the test target, especially since benches are generally built in a release profile, it kind of makes no sense to build the targets in the release profile as well.
Notes
Sorry if this makes no sense or if it's a duplicate.
If instructions on how to reproduce are not clear enough I can provide a simple repository!
Version
The text was updated successfully, but these errors were encountered: