So, I have some library I’m working on in Cargo. This needs tests. Example programs. Unit tests for various details. Integrative tests running the whole thing. Cargo has options for handling all this; great.
But it turns out the tests aren’t so simple; some set-up code is needed for some of the examples and integration tests and should be shared. This isn’t code an end user would want, but code to tailor the library to some hypothetical (and fairly pointless) use.
How can code be shared within a Cargo library project without being in the library? My only thoughts at the moment are (a) as a configuration within the main library (
#[cfg(lib_test_suite)]), (b) as a separate Cargo project or © copy+paste. All three have their disadvantages. Thoughts?