-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: invalidate cache entries for test runs using different timeouts #36134
Comments
Have you found any case where this behaviour is an issue currently? I tend to think that it's probably right that adjusting the timeout doesn't invalidate existing cached tests. When tests take a long time, it's frustrating to have them run again needlessly. If a test varies its behaviour based on the timeout, I think it probably deserves what it gets. |
I wrote a bunch of regression tests for #32471 and they failed because the tests were being cached when I didn't expect. It may be annoying to re-run tests when you change flags, but the general solution to that is to not request those tests when you know you're changing flags... |
In the past, I've worked a lot on projects that had very slow tests. Often there would be one or two packages that timed out and required a If this proposal was accepted, you could run all the tests from the top level with
That doesn't seem like a good idea to me. I'd suggest that it would be better to have an environment variable or a flag that controls that behaviour - I think it would be deeply unintuitive for a test to take longer when the timeout is increased. For your regression tests, perhaps a better solution might be for a test to be able to explicitly mark itself as non-cacheable. |
It seems to me that (And you can always terminate the faster tests earlier by sending them |
That is #23799. (But see specifically #23799 (comment).) |
Another problem with ignoring If I know that my CI system runs with That suggests, at the very least, a much more subtle caching policy: a passing test with a shorter timeout generally implies passing with a longer timeout too, and a passing test with a long timeout should continue pass with any timeout shorter than its observed running time, but a passing result for |
Change https://golang.org/cl/220365 mentions this issue: |
@bcmills, what do you think we should do here? |
I think we should revert the special-case for the (Then we can see if there are any remaining cases where the |
This is about a subtle corner case in the test caching implementation. |
In the resolution to #22633, we started explicitly ignoring the test timeout when computing its cache key:
go/src/cmd/go/internal/test/test.go
Lines 1285 to 1287 in 32b6eb8
The use-case there was to be able to run a set of tests with a short timeout, and then increase that timeout in case of failure without re-running all of the tests.
However, that behavior seems incorrect to me: a test can today vary its behavior based on its timeout by using
flag.Lookup("test.timeout")
or examiningos.Args
directly. We have a pretty comprehensive test that checks for cache invalidation for all kinds of esoteric-but-observable behaviors, such as accessing files or environment variables — it's very surprising for one particular input to escape that check.In #34707 (comment), I even suggested a situation in which a test might want to explicitly vary its behavior based on the timeout: a test using randomized inputs and running with a short timeout might want to check only a few cursory inputs, while a very long (or even unlimited!) timeout might imply a much more exhaustive search.
We do have a tracing hook that checks whether the test happens to observe external environment variables. Something like that might be reasonable for
os.Args
, but we don't have that today.I propose that we revert the special case for
-test.timeout
, and if that proves to be too unpleasant we should add explicit tracking for access to theflag
package and/oros.Args
so that we only ignore-test.timeout
for tests whose behavior verifiably does not depend on the timeout.CC @jayconrod @rogpeppe @matloob
The text was updated successfully, but these errors were encountered: