From ef5f6ac8175e2ee5101a9121e8f2645015dd903b Mon Sep 17 00:00:00 2001 From: Chuck Lever Date: Fri, 7 Aug 2026 12:59:57 -0400 Subject: [PATCH] test: Isolate fixture repositories from global git configuration The test helpers that shell out to git pin author and committer identity through the environment but leave configuration inherited, so a fixture repository behaves differently depending on who runs the suite. With tag.gpgSign set, the bare `git tag v1` in create_merge_repo() becomes a signed annotated tag and fails for want of a message. All three list_shas_in_range tests then abort during fixture setup. A commit.gpgSign or gpg.format setting breaks every other fixture the same way, at its first `git commit`. Point GIT_CONFIG_GLOBAL and GIT_CONFIG_SYSTEM at /dev/null in every git shell-out under src/ and tests/ so a fixture sees only the repository it creates. Fixes: 636e4ea465f2 ("test: add regression tests for list_shas_in_range with merge topology") Signed-off-by: Chuck Lever --- src/database/connection.rs | 3 +++ src/git.rs | 3 +++ src/indexer.rs | 3 +++ src/workdir.rs | 12 ++++++++++++ tests/ambiguous_callees.rs | 3 +++ tests/indirect_calls.rs | 3 +++ tests/revision_scoping.rs | 3 +++ 7 files changed, 30 insertions(+) diff --git a/src/database/connection.rs b/src/database/connection.rs index ee7da02..98c8635 100644 --- a/src/database/connection.rs +++ b/src/database/connection.rs @@ -7854,6 +7854,9 @@ mod tests { let status = std::process::Command::new("git") .args(args) .current_dir(repo) + // Do not inherit developer's git configuration. + .env("GIT_CONFIG_GLOBAL", "/dev/null") + .env("GIT_CONFIG_SYSTEM", "/dev/null") .env("GIT_AUTHOR_NAME", "Semcode Test") .env("GIT_AUTHOR_EMAIL", "semcode@example.com") .env("GIT_COMMITTER_NAME", "Semcode Test") diff --git a/src/git.rs b/src/git.rs index 0704d0c..97e69db 100644 --- a/src/git.rs +++ b/src/git.rs @@ -235,6 +235,9 @@ mod tests { let status = std::process::Command::new("git") .args(args) .current_dir(dir.path()) + // Do not inherit developer's git configuration. + .env("GIT_CONFIG_GLOBAL", "/dev/null") + .env("GIT_CONFIG_SYSTEM", "/dev/null") .env("GIT_AUTHOR_NAME", "Semcode Test") .env("GIT_AUTHOR_EMAIL", "semcode@example.com") .env("GIT_COMMITTER_NAME", "Semcode Test") diff --git a/src/indexer.rs b/src/indexer.rs index a7a9f48..2752ea1 100644 --- a/src/indexer.rs +++ b/src/indexer.rs @@ -1146,6 +1146,9 @@ mod tests { let out = std::process::Command::new("git") .args(args) .current_dir(repo) + // Do not inherit developer's git configuration. + .env("GIT_CONFIG_GLOBAL", "/dev/null") + .env("GIT_CONFIG_SYSTEM", "/dev/null") .env("GIT_AUTHOR_NAME", "test") .env("GIT_AUTHOR_EMAIL", "test@test.com") .env("GIT_COMMITTER_NAME", "test") diff --git a/src/workdir.rs b/src/workdir.rs index d2128eb..733e1c8 100644 --- a/src/workdir.rs +++ b/src/workdir.rs @@ -713,11 +713,17 @@ void hello(void); std::process::Command::new("git") .args(["add", "."]) .current_dir(&repo_path) + // Do not inherit developer's git configuration. + .env("GIT_CONFIG_GLOBAL", "/dev/null") + .env("GIT_CONFIG_SYSTEM", "/dev/null") .output() .unwrap(); std::process::Command::new("git") .args(["commit", "-m", "initial"]) .current_dir(&repo_path) + // Do not inherit developer's git configuration. + .env("GIT_CONFIG_GLOBAL", "/dev/null") + .env("GIT_CONFIG_SYSTEM", "/dev/null") .env("GIT_AUTHOR_NAME", "test") .env("GIT_AUTHOR_EMAIL", "test@test.com") .env("GIT_COMMITTER_NAME", "test") @@ -791,6 +797,9 @@ int multiply(int a, int b) { std::process::Command::new("git") .args(["add", "new.c"]) .current_dir(&repo_path) + // Do not inherit developer's git configuration. + .env("GIT_CONFIG_GLOBAL", "/dev/null") + .env("GIT_CONFIG_SYSTEM", "/dev/null") .output() .unwrap(); @@ -831,6 +840,9 @@ int multiply(int a, int b) { std::process::Command::new("git") .args(["add", "new.c"]) .current_dir(&repo_path) + // Do not inherit developer's git configuration. + .env("GIT_CONFIG_GLOBAL", "/dev/null") + .env("GIT_CONFIG_SYSTEM", "/dev/null") .output() .unwrap(); diff --git a/tests/ambiguous_callees.rs b/tests/ambiguous_callees.rs index 025b1a4..55e6cfd 100644 --- a/tests/ambiguous_callees.rs +++ b/tests/ambiguous_callees.rs @@ -10,6 +10,9 @@ fn git_run(repo: &Path, args: &[&str]) { let status = Command::new("git") .args(args) .current_dir(repo) + // Do not inherit developer's git configuration. + .env("GIT_CONFIG_GLOBAL", "/dev/null") + .env("GIT_CONFIG_SYSTEM", "/dev/null") .env("GIT_AUTHOR_NAME", "Semcode Test") .env("GIT_AUTHOR_EMAIL", "semcode@example.com") .env("GIT_COMMITTER_NAME", "Semcode Test") diff --git a/tests/indirect_calls.rs b/tests/indirect_calls.rs index 17ea0b9..8c57612 100644 --- a/tests/indirect_calls.rs +++ b/tests/indirect_calls.rs @@ -34,6 +34,9 @@ fn git_run(repo: &Path, args: &[&str]) { let status = Command::new("git") .args(args) .current_dir(repo) + // Do not inherit developer's git configuration. + .env("GIT_CONFIG_GLOBAL", "/dev/null") + .env("GIT_CONFIG_SYSTEM", "/dev/null") .env("GIT_AUTHOR_NAME", "Semcode Test") .env("GIT_AUTHOR_EMAIL", "semcode@example.com") .env("GIT_COMMITTER_NAME", "Semcode Test") diff --git a/tests/revision_scoping.rs b/tests/revision_scoping.rs index af4678b..c676004 100644 --- a/tests/revision_scoping.rs +++ b/tests/revision_scoping.rs @@ -11,6 +11,9 @@ fn git_run(repo: &Path, args: &[&str]) { let status = Command::new("git") .args(args) .current_dir(repo) + // Do not inherit developer's git configuration. + .env("GIT_CONFIG_GLOBAL", "/dev/null") + .env("GIT_CONFIG_SYSTEM", "/dev/null") .env("GIT_AUTHOR_NAME", "Semcode Test") .env("GIT_AUTHOR_EMAIL", "semcode@example.com") .env("GIT_COMMITTER_NAME", "Semcode Test")