Is it possible to do a cargo test without it building the examples files?
I have a crate with around 300 example files and it is slow to compile, link and run them each time I want to run the tests. I'd like to disable them so that they only run when I explicitly run cargo test --examples.
Why don't you move the examples to their own crate in your workspace? That way they won't be compiled when testing your main crate, but you'll still be able to do cargo test --workspace to compile everything and run tests.
Just a quick summary to close out on this in case anyone else has the same issue.
I raised this behaviour as an issue/feature request against Cargo Cargo #12430. It was closed/rejected in favour of another overarching feature request that would provide the required behaviour: Cargo #6945.
In the meantime I added this to my ~/.cargo/config.toml:
fast_test = "test --test *"
That way I can run the following to get the required behaviour: