-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
proposal: cmd/go: add flag go test -no-cache
#39056
Comments
go test -no-cache
go test -no-cache
(equivalent to -count=1)
go test -no-cache
(equivalent to -count=1)go test -no-cache
(equivalent to -count=1)
for clarity,
so this is not a request to have Not sure if the title should be updated or not. |
go test -no-cache
(equivalent to -count=1)go test -no-cache
A minor point: we don't currently have any |
I do not think we should switch test caching from opt-out to opt-in. The vast majority of tests should be hermetic and cacheable. It might make sense to have a Even so, I'm not sure that the added clarity of an explicit flag would be worth the added cost of having yet another flag for users to consider. |
Just noting the documentation on this particular point, from
|
If it's decided that caching by default is actually not desirable (what I prefer), that would be great. The community can go about their business and be confident that every time they run If it's decided that caching by default is a good idea, then it would additionally be nice if how go decided to cache was fixed up a bit more as an example:
|
Linking this issue to other things I've found in the community regarding cleaning cache and dealing with it https://stackoverflow.com/questions/48882691/force-retesting-or-disable-test-caching/48882892 |
Do you have data to support this statement? |
We are all in the Go community 😄 Also to note that test caching has been present since Go 1.10 (https://golang.org/doc/go1.10) |
I support giving users the ability to force behavior that the author didn't originally intend, as long as they understand the particular dangers of doing so. I think caching of test results by default is more dangerous than anything else, simply because it's impossible to know what each test is actually doing, so it would make sense to let the author tell the tooling, not the other way around. Even when following best practices such as using "golden files" which are read from disk (for doing such things as HTTP responses or whatever), it's not clear how Go would detect if the file being read has changed or not. It might additionally be useful to add to the |
I'm not sure how the date/period that test caching was introduced is relevant to the conversation. Can you explain? |
That is #23799. |
Test caching has been on by default since Feb 2018. Many of the points you are raising here have been previously discussed in other issues. But, like @bcmills, as someone who has followed the issue tracker relatively closely since that date, the vast majority of people (judging by the relatively small number of issues raised in the tracker) have not had issues with test caching, indeed users benefit significantly from it. That's not to say there aren't cases that test caching does not cover well, and #23799 touches on some of them. |
@myitcv ultimately, at least in scope of this issue, I really just care about intuitiveness of the tooling/flags/options. So I'm 100% ok to keep this focused on just the |
Now that I think more on this. Some tests (if cached), would run |
The test caching logs all files opened by the test and records their size and modification time. If either is different when the test is run again, the cache is invalid, and the test is re-run. |
@ianlancetaylor ah, so the biggest concern then is tests that make network requests? |
It seems to me that the concern in this issue is that On a related topic, see #23799. |
I get the same impression. Perhaps we could point to its effect on the cache more prominently, though it's already in |
@seankhliao you thumbs-down this request. What's your opinion on this? |
I disagree with the addition of a new flag for this, but I do agree there may be a discoverability issue Perhaps one of the example output lines in |
We really try hard not to have "there's more than one way to do it" in Go. |
The point is that
From this perspective, Like the
|
A perfectly reasonable way to interpret |
I agree with what @kortschak says, and the docs already say |
To clarify the documentation something to the effect that without the |
From a UI/UX perspective, there's no valid value for |
@ghostsquad, explicitly passing |
@bcmills if that's true, this feels definitely like a hack, and doesn't support the user experience issue. A user would likely not know that an empty string is a valid value for an option that very much sounds like it should be an integer. |
@bcmills, I don't believe The overall sentiment above though seems to be to leave things as they are, perhaps with better docs, rather than add a second flag with the same meaning. Do I have that right? |
Better docs, and even add output to the test command would be tremendously helpful. |
|
Based on the discussion above, this seems like a likely decline. |
@rsc should I file a separate issue to update the documentation and output of |
@ghostsquad Yes, I think this issue is long enough that a separate issue would be appropriate. Thanks. Please suggest specific changes if you can. Personally I don't see the fact that there is no value for |
Define -count=0 as using the cached results, updating the cache as necessary, and define count > 0 as running the test exactly that many times even if cached. |
No change in consensus, so declined. |
#24573 is closed, but it has all the information.
-count=1
to most people does not mean-no-cache
. It's just not intuitive.This is a request to implement
-no-cache
flag on go test so that this kind of behavior isn't hidden from users.Alternatively (backwards incompatible), since caching of test results is a bit surprising, instead allow uses to decide to cache or not explicitly with
-cache
flag, and set the default to not cache.The text was updated successfully, but these errors were encountered: