-
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
cmd/go/internal/vet: print line numbers appropriately on list errors #36989
Conversation
This PR (HEAD: 0e2e7ab) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/217106 to see it. Tip: You can toggle comments from me using the |
Message from Gobot Gobot: Patch Set 1: Congratulations on opening your first change. Thank you for your contribution! Next steps: Most changes in the Go project go through a few rounds of revision. This can be During May-July and Nov-Jan the Go project is in a code freeze, during which Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Jay Conrod: Patch Set 1: Hey Nick, thanks for working on this. I'd prefer to keep only one copy of TestPackagesFor so that behavior is consistent in 'go vet', 'go test', and 'go list -test'. It's not clear to me the behavior in load.TestPackagesFor is correct, so maybe we can just fix that one by leaving the position on the error. There is some ambiguity here: for an import error, sometimes we should show the chain of imports, and sometimes we should show the file name and line number. When a package can't be imported (because it's internal, main, has a non-canonical import path, doesn't exist, ...), we currently report the error on the imported package rather than the importer. Perhaps this can be addressed in another issue though. cc Bryan, Michael because we've been discussing this lately in the context of golang.org/issue/36188. Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
This PR (HEAD: d005ca5) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/217106 to see it. Tip: You can toggle comments from me using the |
Message from Nick Santos: Patch Set 1:
Hi Jay! Thanks for the detailed comments. I really appreciate it. I like your idea. I pushed a new patch set. It changes the behavior in load.TestPackagesFor so that it preserves the line numbers, then changes the use in 'test' to strip the line numbers. Fortunately, there was a good integration test for the stack-printing behavior (https://github.com/golang/go/blob/master/src/cmd/go/testdata/script/test_import_error_stack.txt), and that helped. Take a look at this version and let me know what you think. Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Jay Conrod: Patch Set 2: Thanks, I tried this out and thought about it a bit more. I think the error messages for imports should be the same (or nearly so) for 'go vet' and 'go test'. If a test directly imports a package that can't be imported for some reason, both commands should show a file and line number. If a test transitively imports a package with an error, both commands should show a stack. So it should be possible to fix this in load.TestPackagesFor without any special case in internal/test. Perhaps the important change is this: in load.TestPackagesFor, if the error is on a package directly imported by the test package, we should show a position. Otherwise (if the error is in a transitively imported package), we should show a stack.
For reference, the stack printing behavior was introduced in CL 12176 as a fix for golang.org/issue/9558. Also, I've added a comment to golang.org/issues/26909 about the ambiguity. Added matloob to reviewers as well. Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
This PR (HEAD: 3578b2f) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/217106 to see it. Tip: You can toggle comments from me using the |
Message from Nick Santos: Patch Set 3:
I uploaded a new patch set. The ImportStack has a weird format that I don't totally understand - it looks like [ "command-line-arguments", "(test)", "real/pkg/name" ]. I added a test for "direct" errors that I think captures the spirit of your suggestion and passes all the tests. Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Jay Conrod: Patch Set 3: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
This PR (HEAD: c4cdc33) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/217106 to see it. Tip: You can toggle comments from me using the |
Message from Nick Santos: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Michael Matloob: Patch Set 4: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Jay Conrod: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Nick Santos: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Bryan C. Mills: Patch Set 4: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
This PR (HEAD: 048ad00) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/217106 to see it. Tip: You can toggle comments from me using the |
Message from Nick Santos: Patch Set 5: (1 comment) Thanks everyone! I pushed up a new patch set with a buttload of new tests that poke at several different combinations of this problem. The new behavior isn't perfect, but is at least a lot better. In particular, the code in load.PackagesForBuild is short-circuiting a lot of the smart-stack-trace-printing logic that this code is trying to do. Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[deleted]
Message from Jay Conrod: Patch Set 5: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Gobot Gobot: Patch Set 5: TryBots beginning. Status page: https://farmer.golang.org/try?commit=e03ef357 Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Gobot Gobot: Patch Set 5: TryBot-Result+1 TryBots are happy. Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Bryan C. Mills: Patch Set 5: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
This PR (HEAD: 5a6a3df) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/217106 to see it. Tip: You can toggle comments from me using the |
Message from Jay Conrod: Patch Set 7: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
This PR (HEAD: ca2984b) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/217106 to see it. Tip: You can toggle comments from me using the |
Message from Nick Santos: Patch Set 7: (1 comment) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Jay Conrod: Patch Set 8: (3 comments) Thanks for fixing this! I have a couple API nits, but this is looking really good. Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Jay Conrod: Patch Set 8: Run-TryBot+1 Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Gobot Gobot: Patch Set 8: TryBots beginning. Status page: https://farmer.golang.org/try?commit=a26e4df6 Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Gobot Gobot: Patch Set 8: Build is still in progress... Other builds still in progress; subsequent failure notices suppressed until final report. Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed. Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Gobot Gobot: Patch Set 8: TryBot-Result-1 3 of 20 TryBots failed: Consult https://build.golang.org/ to see whether they are new failures. Keep in mind that TryBots currently test exactly your git commit, without rebasing. If your commit's git parent is old, the failure might've already been fixed. Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Fixes golang#36173 For reasons that are unclear to me, this commit: golang@f1d5ce0 introduces a TestPackagesFor function that strips line numbers from error messages. This commit introduces a new version of that function for 'go vet' that always keeps the line numbers.
This PR (HEAD: 81c8ef2) has been imported to Gerrit for code review. Please visit https://go-review.googlesource.com/c/go/+/217106 to see it. Tip: You can toggle comments from me using the |
Message from Nick Santos: Patch Set 9: (3 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Bryan C. Mills: Patch Set 9: (8 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Nick Santos: Patch Set 9: Bryan - would it make more sense for you to take this PR over? It sounds like you have pretty strong opinions about the internal details. Which is fine! And makes sense! I don't work in the Go codebase full-time, and don't have a good sense of what internal details matter. But at the same time, it feels like going back and forth on some of these details isn't a particularly effective use of my time or of your yours. No hard feelings on it. I just don't have the context that you do. And it feels like we're spending a lot of time on back-and-forth communicating that context. What do you think? Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Michael Matloob: Patch Set 9:
I'll take this over. Thanks! Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Michael Matloob: Uploaded patch set 10: Run-TryBot+1. Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Michael Matloob: Patch Set 10: (5 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Gobot Gobot: Patch Set 10: TryBots beginning. Status page: https://farmer.golang.org/try?commit=e4e2d932 Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Michael Matloob: Patch Set 10: (I'm not done addressing all the comments yet. Will send more tomorrow) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Bryan C. Mills: Patch Set 11: I rebased CL 185345, and now it has some test failures that might be related. (Specifically, it seems to be emitting smaller import stacks in the noncanonical_import test case.) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Michael Matloob: Uploaded patch set 12: Run-TryBot+1. Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Michael Matloob: Patch Set 12: (2 comments) Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Gobot Gobot: Patch Set 12: TryBots beginning. Status page: https://farmer.golang.org/try?commit=4c730a41 Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Michael Matloob: Uploaded patch set 14: Run-TryBot+1. Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Gobot Gobot: Patch Set 14: TryBots beginning. Status page: https://farmer.golang.org/try?commit=b1eb63df Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Michael Matloob: Uploaded patch set 16: Run-TryBot+1. Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
Message from Gobot Gobot: Patch Set 16: TryBots beginning. Status page: https://farmer.golang.org/try?commit=bf77eede Please don’t reply on this GitHub thread. Visit golang.org/cl/217106. |
This PR is being closed because golang.org/cl/217106 has been abandoned. Replaced with https://go-review.googlesource.com/c/go/+/220718. (The original was a GitHub/Gerrit cl, and because of https://golang.org/issue/24887 , gerritbot would keep fighting us. |
Fixes #36173
For reasons that are unclear to me, this commit:
f1d5ce0
introduces a TestPackagesFor function that strips line numbers from error
messages. This commit introduces a new version of that function for 'go vet'
that always keeps the line numbers.