-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/go/analysis/analysistest: RunWithSuggestedFixes should check against golden file even if the Go file has no suggested fixes #47128
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
Comments
In particular, the issue occurs because the testdata Go file in question has no suggested fixes. So Ideally files that don't have suggested fixes are still compared against a golden file: some test authors may write tests to ensure that no fixes are suggested for a given file, and that the file remains unchanged after applying (the zero) suggested fixes. |
I think there is a reasonable interpretation here that the I think an alternative reading of this as suggesting that it will always compare against a golden file is also kinda reasonable. This would mean tightening the contact of this function. If we tighten the contract of RunWithSuggestedFixes(), we may want another function to act as the generalization of these two modes. If we don't, we might want to clarify the documentation of this function for what happens if there are no suggested edits/no golden file. This change would break existing users that use
I believe you can already write such tests by not specifying a golden file or giving a no-op golden file. But I believe the only way to distinguish between 0 edits and all edits combined are a no-op is by not giving a golden file. This is more implicit, but if there are any edits I believe an error is raised here. It is not clear we need to be able to distinguish the 0 edits and the net no-op cases. |
Thank you for looking into this, @timothy-king. I tend to agree with all the points you made in your comment.
I hadn't read the doc comment on
This is very well put. And I don't think we need to able to distinguish between these two cases as well. So overall, I tend to agree that no changes necessarily need to be made to address this issue. Feel free to close the issue (or move it to a similar appropriate state). |
Closing for now. If someone wants to improve the documentation of |
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?
analysistest.RunWithSuggestedFixes()
.Minimal example repo, along with explanation in README: https://github.com/nishanths/analysistest-golden-issue
What did you expect to see?
I would have expected the test to fail, considering a golden file isn't present.
What did you see instead?
The test passes without error.
The text was updated successfully, but these errors were encountered: