From 2f89acd032b29eea00aad181d5753d1ffb2f81cb Mon Sep 17 00:00:00 2001 From: Samuele Pedroni Date: Fri, 11 Dec 2020 14:41:14 +0100 Subject: [PATCH] testutil: use the original environment when calling shellcheck our own test fixtures might have messed up with it, notably some tests change DBUS_SESSION_BUS_ADDRESS for example --- testutil/exec.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/testutil/exec.go b/testutil/exec.go index d005dc78fc..d5c496f470 100644 --- a/testutil/exec.go +++ b/testutil/exec.go @@ -57,6 +57,8 @@ func shellcheckSeenAlready(script string) bool { return false } +var pristineEnv = os.Environ() + func maybeShellcheck(c *check.C, script string, wholeScript io.Reader) { // MockCommand is used sometimes in SetUptTest, so it adds up // even for the empty script, don't recheck the essentially same @@ -70,6 +72,7 @@ func maybeShellcheck(c *check.C, script string, wholeScript io.Reader) { return } cmd := exec.Command(shellcheckPath, "-s", "bash", "-") + cmd.Env = pristineEnv cmd.Stdin = wholeScript out, err := cmd.CombinedOutput() c.Check(err, check.IsNil, check.Commentf("shellcheck failed:\n%s", string(out)))