forked from mirrors/jj
tests: don't propagate environment variables to tests
We don't want variables from the developer's environment to affect tests. You can make tests fail if you set `XDG_CONFIG_HOME` such that `$XDG_CONFIG_HOME/jj/config.toml` exists and has e.g. an email set. The fix is to not propagate any environment variables. Thanks for @arxanas for pointing this out in #104. We still need to set `$HOME` to prevent configs from being read from the process owner's home directory (because that's what `dirs::config_dir()` seems to fall back to if `$HOME` is not set). By the way, I suspect we'd still not immune to configs from the developers home directory on Windows, because that doesn't seem to be controlled by `$HOME`.
This commit is contained in:
parent
42252a2f00
commit
891641670c
1 changed files with 1 additions and 0 deletions
|
@ -45,6 +45,7 @@ impl TestEnvironment {
|
|||
let mut cmd = assert_cmd::Command::cargo_bin("jj").unwrap();
|
||||
cmd.current_dir(current_dir);
|
||||
cmd.args(args);
|
||||
cmd.env_clear();
|
||||
cmd.env("HOME", self.home_dir.to_str().unwrap());
|
||||
let timestamp = chrono::DateTime::parse_from_rfc3339("2001-02-03T04:05:06+07:00").unwrap();
|
||||
let mut command_number = self.command_number.borrow_mut();
|
||||
|
|
Loading…
Reference in a new issue