-
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: add known variables to go command to the test cache key hash #32285
Comments
/cc @bcmills @jayconrod |
Change https://golang.org/cl/179040 mentions this issue: |
As noted in #32107 (comment):
|
Reading known environment variables in I don't think we should add special cases for any specific environment variable that tests might access. Unfortunately, we can't tell exactly what environment variables a test accesses through subprocesses. In principle, we could avoid caching test results if a test starts a subprocess, but this would prevent caching far more often than necessary. |
Hmm! We could examine the Another alternative might be to whitelist a set of “known volatile” environment variables (PIDs and such) and key the cache on everything else if a subprocess is started. |
Would you mind describing more details here? What do you mean "internal/testenv.GoToolPath AFAIK, |
I mean that we can iterate over the variables listed in |
@bcmills would you mind pointing out which part of code does that thing. It's not clear to me that how can |
@bcmills I modified
then running the test, no output at all. What did I missed? |
@cuonglm, it shouldn't produce any extra output — just extra metadata in the cache, so that if you change one or more of those variables to a new combination and re-run the |
@bcmills Thanks, the test is not cached now when I change |
@bcmills @jayconrod should we add a note in changelog for this |
Since it only affects the tests of the standard library, I don't think it needs a release note. (It's a nice improvement for folks working on the Go toolchain, but I don't think most users will notice — users don't often run tests that depend on That said, we probably do need more documentation in the community on the general topic of “how to get your tests to play well with caching”. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
What did you expect to see?
GO111MODULE=off go test cmd/vet
won't be cached, the test fail:What did you see instead?
Test was cached, test pass.
The text was updated successfully, but these errors were encountered: