macro_rules! is_running_in_test_env {
() => { ... };
}Expand description
Detect unit tests in the calling crate, nextest, or devimint.
The macro evaluates cfg!(test) in the calling crate. Inside a dependency’s
function, cfg!(test) describes that dependency’s build and cannot detect
the consuming crate’s unit tests. Code compiled without cfg(test) still
needs the runtime signal NEXTEST or FM_IN_DEVIMINT.
use fedimint_core::envs::{FM_IN_DEVIMINT_ENV, is_env_var_set, is_running_in_test_env};
// Doctests compile without cfg(test), like normal applications.
assert!(!cfg!(test));
assert_eq!(
is_running_in_test_env!(),
is_env_var_set("NEXTEST") || is_env_var_set(FM_IN_DEVIMINT_ENV),
);