Description
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 examining os.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 the flag
package and/or os.Args
so that we only ignore -test.timeout
for tests whose behavior verifiably does not depend on the timeout.