-
Notifications
You must be signed in to change notification settings - Fork 7
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
A flag to unset all pre-existing variables #24
Comments
That's a good idea. Though I don't think we need a new flag, this can be done already today with something along the lines of: let vars_to_unset = std::env::vars().map(|(key, _value)| (key, None)).collect();
temp_env::with_vars(
[
vars_to_unset,
vec![("MY_VAR".to_string(), Some("my_value"))],
]
.concat(),
|| {
println!("vmx: env without pre-existing vars: {:?}", std::env::vars());
},
); Does that solve your problem? |
Calling But I agree it'll work if everyone is purely adding additional variables instead of unsetting some. |
If I understand it correctly, you would set the |
But that would force every tests to run the setup even if they don't necessarily need a clean environment. Any one test missing the setup && unset some variables in temp_env will cause the problem I described earlier. |
It would make tests more reproducible.
The text was updated successfully, but these errors were encountered: