I just discovered how to add example binaries to a library crate thanks to Add examples to your Rust libraries
This is great, and I love the fact the examples get rebuilt automatically as part of cargo test.
That said... given that they are rebuilt, is there an idiomatic way to use them in the tests? E.g., I could run the example program with some parameters and examine its output.
To do this, (1) cargo must build the examples before running any test and (2) the examples should be in a predictable location.
(2) is trivial - the binaries are in target//examples/ which is easy enough (it does require me to detect which mode the test is being executed at).
Is (1) guaranteed though?