stalwartlabs / mail-auth

DKIM, ARC, SPF and DMARC library for Rust
https://docs.rs/mail-auth/
Apache License 2.0
82 stars 13 forks source link

test feature #9

Closed djc closed 1 year ago

djc commented 1 year ago

The design in https://github.com/stalwartlabs/mail-auth/commit/4383fcc008014d0ebf2e798166de0166f9aa2982 seems a little surprising. What is the test feature intended to do? Is there a reason not to use #[cfg(test)] directly? It seems kinda strange that running the tests requires the test feature (otherwise a bunch of tests fail). Usually Cargo features should be additive, such that code compiles (and passes tests) whether the feature is enabled or not.

mdecimus commented 1 year ago

The test feature enables the mock resolver and disables all DNS lookups. I needed to be able to use this feature from outside the library but cargo does not yet support automatically enabling features when running cargo test. Anyway, I fixed it with the following workaround:

#[cfg(any(test, feature = "test"))]