-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/go,testing: GOWORK value does not invalidate test cache #60052
Comments
In general the cache key for a test only includes the factors that determine what's in the resulting binary and the environment variables and files explicitly accessed by the test itself. (And #33976 means that the binary doesn't depend on the build list as much as it probably should either.) So if all of the packages are loaded from the same source files with or without But in this case, I guess the environment variable gets threaded through |
I've filed #60057 to consider the more general |
In the meantime, a workaround might be to do something like this in a test function: for _, kv := range os.Environ() {
if k, _, ok := strings.Cut(kv, "="); ok {
_ = os.Getenv(k)
}
} Note that #59849 suggests this has to be in the test function itself rather than in |
Thanks! I think you have confirmed that this is WAI, and I will defer discussion to #60057.
Thanks for the suggestion, but I am loath to replace all of our calls to os.Environ.
That seems like a consequence of #44625 (comment). Let's close this as unactionable, thanks. |
This may or may not be a bug. While investigating a gopls test that fails when using a go.work file, I noticed that the value of
GOWORK
is apparently not used in the test cache key:Observe that we get a cache hit for the successful test run when
GOWORK=off
is set, even whenGOWORK=off
is not set.If I had to guess, I'd say that there is an assumption that
GOWORK
values affect the build list, and therefore ifGOWORK
changes the build list will change, and therefore we don't need to hash the actualGOWORK
value into the cache key. However, as we see here this may not be sufficient if the test in question actually invokes the Go command. (note that my GOWORK uses exactly x/tools and x/tools/gopls, so there is likely no difference in the build list when run from the gopls module, which has a replace directive for x/tools).@bcmills @matloob what do you think? Should the value of GOWORK be part of the cache key? If not, please feel free to close this issue.
The text was updated successfully, but these errors were encountered: