Closed Grinkers closed 8 months ago
I'm OK with the change but my suggestion is to create a tests/lib.rs and add a single
#![allow(dead_code)]
there
I believe tests/
is a special case. Each mod inside ends up being compiled as a completely separate crate, so this doesn't work. I actually ran into this issue with edn-rs
trying to add a helper function for all mods https://github.com/edn-rs/edn-rs/blob/3965bc3221d79b883a7059d7ce72c4c5c2eee366/tests/deserialize.rs#L10. The workarounds involve directly importing rust files, which is just way more ugly than a couple repeated snippets.
It's further weird with the crate trybuild
being used, which ends up in a completely separate compile process for each file.
https://github.com/edn-rs/edn-derive/blob/main/tests/progress.rs
Edited my above link. Also found what I was originally thinking
https://doc.rust-lang.org/book/ch11-03-test-organization.html#the-tests-directory
Each file in the tests directory is a separate crate
I was able to clean up edn-rs
's lib.rs
. I don't think it's really any more clean, but better for long-term usage. I don't think this would work with attributes here, especially with trybuild
. It's really quite weird how tests/
gets treated so differently.
https://github.com/edn-rs/edn-rs/pull/150/commits/7efaab53a558b445cd7141bdeb0d6b3d5ac8ab7a
@naomijub @evaporei
merging unless either of you have any other ideas. Adding a lib.rs
is a no-op and I don't think trybuild can inject attributes. Each test is actually its own binary.
Just less noise.