Golang 1.10 introduced caching for test, but there is no obvious way to disable test caching. So the question is, how to temporal dislable it and how to force rebuild it. I did read the documentation: https://golang.org/cmd/go/#hdr-Build_and_test_caching but did not found any obvious answer to that question.
Asked
Active
Viewed 4,832 times
9
-
Pass -count=1. I agree that it's not obvious, but it's the canonical way to do it. – Peter Apr 24 '18 at 10:15
-
Thanks, while its correct the dublicate question (which I failed to find my self) has even better answer providing also a way to clear cache. – Macilias Apr 24 '18 at 12:24
-
Try go clean -testcache – apostrophedottilde May 12 '19 at 17:43
1 Answers
14
The idiomatic way to bypass test caching is to use -count=1. This is the recommended way for doing that in release note as well
The go test command now caches test results: if the test executable and command line match a previous run and the files and environment variables consulted by that run have not changed either, go test will print the previous test output, replacing the elapsed time with the string “(cached).” Test caching applies only to successful test results; only to go test commands with an explicit list of packages; and only to command lines using a subset of the -cpu, -list, -parallel, -run, -short, and -v test flags. The idiomatic way to bypass test caching is to use -count=1.

Sarath Sadasivan Pillai
- 6,737
- 29
- 42
-
Thanks, while its correct the dublicate question (which I failed to find my self) has even better answer providing also a way to clear cache. – Macilias Apr 24 '18 at 12:24