mod common;
const SCENARIO: &str = "poisoned_global_config_scenario";
#[test]
#[ignore = "run by ambient_global_git_config_does_not_reach_the_test_repositories"]
fn poisoned_global_config_scenario() {
let dir = common::repo_with(&[("f", "a\nb\nc\n")]);
let diff = common::diff_after(&dir, &[("f", "a\nB\nc\n")]);
assert!(
diff.contains("--- a/f") && diff.contains("+++ b/f"),
"path prefixes must survive an ambient diff.noprefix: {diff}"
);
assert!(
!diff.contains('\r'),
"an ambient core.autocrlf must not reach the diff: {diff:?}"
);
}
#[test]
fn ambient_global_git_config_does_not_reach_the_test_repositories() {
let cfg = tempfile::NamedTempFile::new().unwrap();
std::fs::write(
cfg.path(),
"[diff]\n\tnoprefix = true\n[core]\n\tautocrlf = true\n",
)
.unwrap();
let exe = std::env::current_exe().expect("the test binary knows its own path");
let out = std::process::Command::new(exe)
.args(["--exact", "--ignored", "--test-threads", "1", SCENARIO])
.env("GIT_CONFIG_GLOBAL", cfg.path())
.output()
.expect("re-running this test binary");
let stdout = String::from_utf8_lossy(&out.stdout);
assert!(
out.status.success(),
"the scenario failed under a poisoned GIT_CONFIG_GLOBAL:\n{stdout}{}",
String::from_utf8_lossy(&out.stderr)
);
assert!(
stdout.contains("1 passed"),
"the child run did not execute the scenario:\n{stdout}"
);
}