cargo test --help says:
--example NAME ... Check that the specified examples compile
--examples Check that all examples compile
but what actually happens when you run cargo test --examples is that the examples are compiled and tested just like any other test, and the binary written to target/debug/examples/$NAME is a test-runner rather than the actual example binary.
This may seem harmless but it causes a surprising difference in behaviour when e.g. running cargo test && target/debug/examples/$NAME vs cargo test --examples && target/debug/examples/$NAME.
Uncovered by a proposed addition to #5146.
cargo test --helpsays:but what actually happens when you run
cargo test --examplesis that the examples are compiled and tested just like any other test, and the binary written totarget/debug/examples/$NAMEis a test-runner rather than the actual example binary.This may seem harmless but it causes a surprising difference in behaviour when e.g. running
cargo test && target/debug/examples/$NAMEvscargo test --examples && target/debug/examples/$NAME.Uncovered by a proposed addition to #5146.