2 stable releases

1.1.0 Sep 3, 2024
1.0.0 Mar 25, 2023

#289 in Procedural macros

Download history 299/week @ 2024-09-17 295/week @ 2024-09-24 483/week @ 2024-10-01 240/week @ 2024-10-08 400/week @ 2024-10-15 242/week @ 2024-10-22 395/week @ 2024-10-29 295/week @ 2024-11-05 250/week @ 2024-11-12 1714/week @ 2024-11-19 1162/week @ 2024-11-26 362/week @ 2024-12-03 232/week @ 2024-12-10 251/week @ 2024-12-17 67/week @ 2024-12-24 88/week @ 2024-12-31

671 downloads per month

MIT license

3KB

Needs environment variable

Skip code (such as a test) at compile time if an environment variable is undefined.

Example

some_test will not be compiled if SOMEENVIRONMENTVARIABLE is not defined:

use needs_env_var::*;

#[needs_env_var(SOMEENVIRONMENTVARIABLE)]
#[test]
fn some_test() {
    assert!(1 == 1);
}

// or if its specified value not matched
#[needs_env_var(SOMEENVIRONMENTVARIABLE = 1)]
#[test]
fn some_test() {
    assert!(1 == 1);
}


#[needs_env_var(SOMEENVIRONMENTVARIABLE=1)]
#[test]
fn some_test() {
    assert!(1 == 1);
}

Note: As needs_env_var is evaluated at compile time you need to force a re-compilation an environment variable is defined after compilation, e.g. with cargo clean.

No runtime deps