-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
Spent some time debugging problem in tests using temp_env::with_vars_unset(). Even though it's used only in one test, it could interfere with the rest tests, because uses unsafe fn std::env::set_var.
I think it's worth noting that potential problem at README.md. I may do a PR if you're okay with that.
Here is zipped example of code setup that shows the problem.
Same issue happens when I use temp_env::with_var with env variable export X=value
#[cfg(test)]
mod tests {
use std::{thread::sleep, time::Duration};
#[test]
fn test_unset() {
temp_env::with_var("X", Some("blah"), || {
sleep(Duration::from_millis(10));
assert_eq!(std::env::var("X").unwrap(), "blah");
});
}
#[test]
fn test_read() {
sleep(Duration::from_millis(1));
assert_eq!(std::env::var("X").unwrap(), "value");
}
}Second test test_read fails, because gets "blah"
Metadata
Metadata
Assignees
Labels
No labels