]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: respect GODEBUG in test cache
authorRuss Cox <rsc@golang.org>
Sat, 9 Mar 2024 00:29:27 +0000 (19:29 -0500)
committerGopher Robot <gobot@golang.org>
Sat, 9 Mar 2024 22:23:53 +0000 (22:23 +0000)
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 <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>

src/cmd/go/internal/test/test.go
src/cmd/go/testdata/script/test_cache_inputs.txt

index 08fac5f3955059a0269291535279b6af5aedcc7e..f1555fd5d42b7c2b3f270e911d67c614422c5f4e 100644 (file)
@@ -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 {
index 1868da984203859a90bd6f89c3263c6970cbc022..68a700b11607637c3ce7a6b9e18cdde267cc7d57 100644 (file)
@@ -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\)'