Crates.io | needs_env_var |
lib.rs | needs_env_var |
version | 1.1.0 |
source | src |
created_at | 2023-03-25 08:20:07.592901 |
updated_at | 2024-09-03 19:11:52.109057 |
description | Skip compilation if environment variable is missing |
homepage | |
repository | https://github.com/HerrMuellerluedenscheid/needs_env_var |
max_upload_size | |
id | 819998 |
size | 4,596 |
Skip code (such as a test) at compile time if an environment variable is undefined.
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
.