From 47d4295f924bca6f1852622aabc3d3876a3f06d8 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 8 Mar 2024 19:29:27 -0500 Subject: [PATCH] cmd/go: respect GODEBUG in test cache GODEBUG affects test execution but was not being tracked. Fixes #66213. Fixes #65436. Change-Id: I3ac3c397f0c6fa46cd9be0d22d03020d0632f64f Reviewed-on: https://go-review.googlesource.com/c/go/+/570259 Reviewed-by: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI Auto-Submit: Russ Cox --- src/cmd/go/internal/test/test.go | 2 ++ src/cmd/go/testdata/script/test_cache_inputs.txt | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/src/cmd/go/internal/test/test.go b/src/cmd/go/internal/test/test.go index 08fac5f395..f1555fd5d4 100644 --- a/src/cmd/go/internal/test/test.go +++ b/src/cmd/go/internal/test/test.go @@ -1859,6 +1859,8 @@ var testlogMagic = []byte("# test log\n") // known to testing/internal/testdeps/ func computeTestInputsID(a *work.Action, testlog []byte) (cache.ActionID, error) { testlog = bytes.TrimPrefix(testlog, testlogMagic) h := cache.NewHash("testInputs") + // The runtime always looks at GODEBUG, without telling us in the testlog. + fmt.Fprintf(h, "env GODEBUG %x\n", hashGetenv("GODEBUG")) pwd := a.Package.Dir for _, line := range bytes.Split(testlog, []byte("\n")) { if len(line) == 0 { diff --git a/src/cmd/go/testdata/script/test_cache_inputs.txt b/src/cmd/go/testdata/script/test_cache_inputs.txt index 1868da9842..68a700b116 100644 --- a/src/cmd/go/testdata/script/test_cache_inputs.txt +++ b/src/cmd/go/testdata/script/test_cache_inputs.txt @@ -23,6 +23,14 @@ go test testcache -run=TestLookupEnv go test testcache -run=TestLookupEnv stdout '\(cached\)' +# GODEBUG is always read +env GODEBUG=asdf=1 +go test testcache -run=TestLookupEnv +! stdout '\(cached\)' +go test testcache -run=TestLookupEnv +stdout '\(cached\)' +env GODEBUG= + env TESTKEY=y go test testcache -run=TestLookupEnv ! stdout '\(cached\)' -- 2.48.1