-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_with::env
executes even if env var is unset
#60
Comments
hmm... I check on this, with following files. // src/main.rs
#[serial_test::serial]
#[test_with::env(CALDAV_SERVER)]
#[tokio::test]
async fn test_fetch_missing() {} # Cargo.toml
[dependencies]
tokio = { version = "1.25.0", features = ["full"] }
[dev-dependencies]
serial_test = { version = "1.0.0", default-features = false, features = ["async"] }
test-with = { version = "0.9.6", default-features = false }
Could you do If it still have issue, could you let me know about what rust version you are using? |
Huh, I ran On the terminal where > cargo test test_fetch_missing
Finished test [unoptimized + debuginfo] target(s) in 0.05s
Running unittests src/lib.rs (target/debug/deps/libdav-98ea0c7ef4059abc)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 5 filtered out; finished in 0.00s
Running tests/caldav.rs (target/debug/deps/caldav-63cd50a1eca166b7)
running 1 test
test test_fetch_missing ... ignored, because variable CALDAV_SERVER not found
test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 3 filtered out; finished in 0.00s
Running unittests src/main.rs (target/debug/deps/vdirsyncer-430987d2581c901c)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
Running unittests src/lib.rs (target/debug/deps/vstorage-fe538d3663535938)
running 0 tests
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 11 filtered out; finished in 0.00s
> echo $CALDAV_SERVER
http://localhost:8000 |
Is it possible that the variable is being checked at build-time and not at runtime? |
Yeh, I hope I can solve this in runtime, so I write it down in the Readme and also make a post on Reddit. A lot of people want this issue to be solved. And there is also an implementation but not accepted I hope the Rust team can consider this, but @Mark-Simulacrum is against solving the issue here. Somehow Rust is a little away from a useful system programing language. If this is not a reasonable use case, people will not write a macro inside a string like this. |
BTW, the runtime issue is already tracked by another issue, if there is nothing more please close it. Thanks. |
It's right there in the readme, I must have missed it 🤦 Sorry for the noise. |
@WhyNotHugo no worries, it is not intuitive. However, for most cases, you will change the code in development, or start empty in the CI server, you only need to |
I've checked out #55 and I have test with macros in this order:
However, the test is executed even if
CALDAV_SERVER
is unset. This is my dependency tree:Any ideas? The full repo is at https://git.sr.ht/~whynothugo/vdirsyncer-rs, branch
test_with
.The text was updated successfully, but these errors were encountered: