-
Notifications
You must be signed in to change notification settings - Fork 17.6k
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: cache test results in go test #11193
Comments
This would be amazing for juju. Our tests take on the order of 5-10 minutes depending on the speed of your hardware. |
Worth adding another request at the same time: some tests have test data - For a fun but complex example, one of our tests parses example JSON and
|
What hardware are you running, it's more like 1/2 an hour for me, even the Ci machines with 8 cores can't do it in under 18
|
@davecheney 2013 XPS 15 (9530) It's probably the drive that makes it so much faster for me. I also run with gomaxprocs=8. |
This program is a sketch of a solution for golang/go#11193.
I wrote rsc.io/gt for this as a first draft. It seems okay, but if we're going to go down this route we need to capture all the relevant context - external files, environment variables, and so on - in the cache key. That will require significantly more design. |
It would be impossible to automatically track down all possible dependencies on external state (e.g. database contents, network interactions), so it seems like a line must be drawn in the sand, and users must understand where that line is and how it determines when they can rely on the caching mechanism. Right now, it looks like it only hashes the source files, and to me that seems like a simple and easy to understand demarcation. It may be crude, but that also means it's simple and easy to remember. Our tests take about 3.5 minutes and getting that down to a small fraction for incremental changes is really nice. I'm going to start using gt regularly and see how it goes. So far, so good. |
Without this enhancement, Go is adverse to TDD. Just adding dependencies on gorm and sqlite adds a 20s overhead to every |
Gabe, this is because you are recompiling sqlite every time. Use go install On Thu, 30 Jun 2016, 09:45 Gabe Kopley notifications@github.com wrote:
|
Whew, thanks Dave! We're all good :) |
I would second this. Taint analysis of input variables and tracking external state changes is not simple. Rather than making the implementation of test case output caching very complex, I'd much rather have a simple underlying principle which is easy to reason about for when test cases are re-run. And, hashing of source file content is just that, simple and still rather effective. If the file path of a testdata file change, the test would be re-run. If the URL of a test case changes, the test would be re-run. Easy to reason about and still effective. A solution which attempts to track what files are actually used in a test case is bound to miss some, and thus making it difficult to reason about. |
If this is just based on source files (and possibly testdata), would it make sense if it was opt-in? Something like |
This makes it much less likely for developers to realize they have flaky tests :( |
@tv42 That is a valuable consideration. In other language ecosystems the tests are often ran in random order to help weed out (unintended) interdependencies and other flaky behaviour. Caching results is one way to make tests run faster, certainly not the only way. |
Change https://golang.org/cl/75631 mentions this issue: |
Is there a way to turn this feature off, to force that tests be re-run? I'm trying to run some x/net tests on Windows which behave differently depending on running user's privileges. If I run the tests once as a regular user and then again as Administrator, it uses the cache and doesn't re-run tests that were previously skipped to see if they pass. |
@tmm1, yes, see the docs and Russ's announcement. Both include instructions for turning caching off. See https://tip.golang.org/cmd/go/ and search for "cach". In particular:
|
Scenario:
Detailed example:
I hope this will be fixed, Addendum: with
|
@quasilyte discussion about that is ongoing in #22593. |
It would be nice to have a mode for go test that cached test results, so that you could change a package and then do 'go test ...' and have it only actually rerun the tests that depend on that package.
This comes up especially in larger trees.
This is not trivial.
@thockin @joeshaw
The text was updated successfully, but these errors were encountered: