Skip to content

Commit

Permalink
Mask insta env vars in integration tests (#579)
Browse files Browse the repository at this point in the history
  • Loading branch information
max-sixty committed Sep 1, 2024
1 parent ef7abb8 commit 02665ea
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions cargo-insta/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,25 @@ impl TestProject {
}
fn cmd(&self) -> Command {
let mut command = Command::new(env!("CARGO_BIN_EXE_cargo-insta"));
// Remove environment variables so we don't inherit anything (such as
// `INSTA_FORCE_PASS` or `CARGO_INSTA_*`) from a cargo-insta process
// which runs this integration test.
for (key, _) in env::vars() {
if key.starts_with("CARGO_INSTA") || key.starts_with("INSTA") {
command.env_remove(&key);
}
}
// Turn off CI flag so that cargo insta test behaves as we expect
// under normal operation
command.env("CI", "0");

command.current_dir(self.workspace_dir.as_path());
// Use the same target directory as other tests, consistent across test
// run. This makes the compilation much faster (though do some tests
// tread on the toes of others? We could have a different cache for each
// project if so...)
command.env("CARGO_TARGET_DIR", target_dir());
// Turn off CI flag so that cargo insta test behaves as we expect
// under normal operation
command.env("CI", "0");

command
}

Expand Down

0 comments on commit 02665ea

Please sign in to comment.