diff --git a/cmd/bd/dolt_autostart_lifecycle_integration_test.go b/cmd/bd/dolt_autostart_lifecycle_integration_test.go index d73337bd08..947ff4892c 100644 --- a/cmd/bd/dolt_autostart_lifecycle_integration_test.go +++ b/cmd/bd/dolt_autostart_lifecycle_integration_test.go @@ -38,6 +38,9 @@ func TestE2E_AutoStartedRepoLocalServerPersistsAcrossCommands(t *testing.T) { "BEADS_DOLT_SERVER_PORT=", "BEADS_DOLT_PORT=", "BEADS_DOLT_SHARED_SERVER=", + "GIT_TERMINAL_PROMPT=0", + "SSH_ASKPASS=", + "GIT_ASKPASS=", ) initOut, initErr := runBDExecWithBinary(t, bdBinary, tmpDir, env, "init", "--backend", "dolt", "--prefix", "test", "--quiet") diff --git a/cmd/bd/test_helpers_test.go b/cmd/bd/test_helpers_test.go index ca53496368..d3ae2fb646 100644 --- a/cmd/bd/test_helpers_test.go +++ b/cmd/bd/test_helpers_test.go @@ -373,6 +373,7 @@ func openExistingTestDB(t *testing.T, dbPath string) (*dolt.DoltStore, error) { func runCommandInDir(dir string, name string, args ...string) error { cmd := exec.Command(name, args...) cmd.Dir = dir + cmd.Env = testEnvNoPrompt() return cmd.Run() } @@ -380,6 +381,7 @@ func runCommandInDir(dir string, name string, args ...string) error { func runCommandInDirWithOutput(dir string, name string, args ...string) (string, error) { cmd := exec.Command(name, args...) cmd.Dir = dir + cmd.Env = testEnvNoPrompt() output, err := cmd.Output() if err != nil { return "", err @@ -387,6 +389,15 @@ func runCommandInDirWithOutput(dir string, name string, args ...string) (string, return strings.TrimSpace(string(output)), nil } +// testEnvNoPrompt returns the current environment with git auth prompts +// suppressed. Prevents ksshaskpass/SSH_ASKPASS popups during tests that +// configure fake git remotes (e.g. github.com/test/repo.git). +func testEnvNoPrompt() []string { + env := os.Environ() + env = append(env, "GIT_TERMINAL_PROMPT=0", "SSH_ASKPASS=", "GIT_ASKPASS=") + return env +} + // captureStderr captures stderr output from fn and returns it as a string. // Uses stdioMutex to prevent races with concurrent os.Stderr redirection. func captureStderr(t *testing.T, fn func()) string {