Skip to content

cmd/go: "go test" seems to cache test build output when GODEBUG changes #51561

@mvdan

Description

@mvdan

I was using GODEBUG=inittrace=1 to get some quick stats on the init cost of some packages via go test, and I noticed that even after I unset the variable, its output was still around - presumably via Go's cache.

As a repro:

$ go version
go version devel go1.19-c6d9b38dd8 Wed Mar 9 06:51:37 2022 +0000 linux/amd64
$ cd $(go env GOROOT)/src/encoding/json
$ GODEBUG=inittrace=1 go test -c -vet=off 2>&1 | wc -l
625
$ go test -c -vet=off 2>&1 | wc -l
488

It's unclear why the number of lines diminishes, but they're all still inittrace output.

go build does not show this bug, so presumably the bug is with the test cache:

$ GODEBUG=inittrace=1 go build 2>&1 | wc -l
137
$ go build 2>&1 | wc -l
0

Perhaps Go's cache should be taught to include GODEBUG as part of cache key hashes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions