ok/jj
1
0
Fork 0
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:
Martin von Zweigbergk 2022-03-05 18:35:19 -08:00 committed by Martin von Zweigbergk
parent 42252a2f00
commit 891641670c

View file

@ -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();