testing: feature request: mechanism to disable test caching for specific unit tests #34635
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
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?
I'm writing integration tests using the
testing
package that are triggered via build tags; e.g.:Due to the nature of the integration tests their results should never be cached as the systems they are integrating against are always changing.
What did you expect to see?
A mechanism to disable caching for specific test functions.
What did you see instead?
Mechanisms for either clearing the cache for all tests or disabling the cache for all test.
Workaround
Can currently workaround this issues by running tests twice:
go test ./...
-count=1 -run=...
.This workaround requires that all tests that should never be cached have a regex pattern that be be used; forcing all these test to include the phrase
NoCache
or something else. These tests would also still need to be protected by requiring a build tag to prevent them from being run in step1
.Proposal
Add a
NoCache()
method to thetesting.T
struct that would disable the specific method from being cached.The text was updated successfully, but these errors were encountered: