-
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
x/tools/gopls: friction working with internal/lsp/tests #54845
Comments
Change https://go.dev/cl/431843 mentions this issue: |
Change https://go.dev/cl/431844 mentions this issue: |
Disable logging for lsp tests: logs are not scoped to the failing test and are therefore misleading. For golang/go#54845 Change-Id: I232e4cfc114382121923e8e697452007793ec3c9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/431843 gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Findley <rfindley@google.com>
Change https://go.dev/cl/405254 mentions this issue: |
Change https://go.dev/cl/432138 mentions this issue: |
Data.Golden is called from subtests: use the *testing.T from the caller, so that we can get a more meaningful failure. For golang/go#54845 Change-Id: I136df0c6a7a11bcf364b78ecac42ba2b51a15bb0 Reviewed-on: https://go-review.googlesource.com/c/tools/+/431844 Reviewed-by: Alan Donovan <adonovan@google.com> Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Change https://go.dev/cl/432336 mentions this issue: |
Change https://go.dev/cl/432337 mentions this issue: |
Change https://go.dev/cl/432955 mentions this issue: |
Suppress output in gopls command line tests, similarly to CL 431843. For golang/go#54845 Change-Id: I7f1e1de52c9a8fb0d902bfdd61bc99d4e2e308b9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/432955 Reviewed-by: Alan Donovan <adonovan@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com>
The documentSymbols handler joined syntax information with type information, meaning that it was only able to satisfy requests for files in valid workspace packages. However, the value added by type information was limited, and in many cases could be derived from syntax alone. For example, while generating symbols for a const declaration, we don't need the type checker to tell us that the symbol kind is const. Refactor the documentSymbols handler to derive symbols from syntax alone. This leads to some simplifications from the code, in addition to eliminating the dependency on package data. Also, simplify symbol details to just use types.ExprString, which includes some missing information such as function return values. Also, update handling to support Go 1.18 type embedding in interfaces. Notably, this reverts decisions like golang/go#31202, in which we went to effort to make the symbol kind more accurate. In my opinion (and the opinion expressed in golang/go#52797), the cost of requiring type information is not worth the minor improvement in accuracy of the symbol kind, which (as far as I know) is only used for UI elements. To facilitate testing (and start to clean up the test framework), make several simplifications / improvements to the marker tests: - simplify the collection of symbol data - eliminate unused marks - just use cmp.Diff for comparing results - allow for arbitrary nesting of symbols. - remove unnecessary @symbol annotations from workspace_symbol tests -- their data is not used by workspace_symbol handlers - remove Symbol and WorkspaceSymbol handlers from source_test.go. On inspection, these handlers were redundant with lsp_test.go. Notably, the collection and assembly of @symbol annotations is still way too complicated. It would be much simpler to just have a single golden file summarizing the entire output, rather than weaving it together from annotations. However, I realized this too late, and so it will have to wait for a separate CL. Fixes golang/go#52797 Fixes golang/vscode-go#2242 Updates golang/go#54845 Change-Id: I3a2c2d39f59f9d045a6cedf8023ff0c80a69d974 Reviewed-on: https://go-review.googlesource.com/c/tools/+/405254 gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Alan Donovan <adonovan@google.com>
- simplify collection to use an expected span.Span and use mustRange - remove the source_test.go version of the test, as it is redundant For golang/go#54845 Change-Id: I3a7da8547e27dc157fb513486a151031ec135746 Reviewed-on: https://go-review.googlesource.com/c/tools/+/432138 gopls-CI: kokoro <noreply+kokoro@google.com> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
In order to narrow usage of tests.Data.t, use the mustRange helper in more places. For golang/go#54845 Change-Id: I446ca520fa76afb2bc10c1fd5a5765859176dd6a Reviewed-on: https://go-review.googlesource.com/c/tools/+/432336 Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com>
The marker function collectCompletionItems required at least three arguments. Express this in its signature, leaving a final variadic argument for documentation. I considered just making this final argument mandatory, but opted for minimizing the diff given that there are 400+ existing @item annotations. With this change the only use of tests.Data.t is in mustRange. Since conversion to range should always succeed, I switched this usage to a panic and removed the t field. For golang/go#54845 Change-Id: I407f07cb85fa1356ceb6dba366007f69d1b6a068 Reviewed-on: https://go-review.googlesource.com/c/tools/+/432337 Reviewed-by: Alan Donovan <adonovan@google.com> Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Change https://go.dev/cl/434635 mentions this issue: |
Change https://go.dev/cl/434636 mentions this issue: |
Update the reset_golden.sh script to run the ./test and ./internal/lsp directories, following the deprecation of ./internal/lsp/cmd and ./internal/lsp/source tests. Also, fix it to generate golden data for tests that only run at 1.17 and earlier. Use the newly fixed script to sync the golden data. For golang/go#54845 Change-Id: I2b42dac91cf1c7e2e8e25fd2aa8ab23c91e05c6c Reviewed-on: https://go-review.googlesource.com/c/tools/+/434635 Reviewed-by: Alan Donovan <adonovan@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Update gopls to handle the new form of "undeclared name: ..." error messages, "undefined: ...", and update tests to be tolerant of both. Also do some minor cleanup of test error messages related to mismatching diagnostics. With this change, TryBots should succeed at CL 432556. Updates golang/go#54845 Change-Id: I9214d00c59110cd34470845b72d3e2f5e73291c1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/434636 Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
Change https://go.dev/cl/435355 mentions this issue: |
Tolerate the new form of the "... imported but not used" error message, to allow landing this change in go/types. Along the way, improve the test output when comparing diagnostics, and formatting results. For golang/go#54845 Change-Id: I998d539f82e0f70c85bdb4c40858be5e01dd08b6 Reviewed-on: https://go-review.googlesource.com/c/tools/+/435355 gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Robert Findley <rfindley@google.com>
@adonovan and I just discussed where to go with this next, and there are a few major problems we'd like to solve:
We just brainstormed a design for solving all of these problems:
To illustrate what I mean, here is a hypothetical implementation of an isolated marker test: func TestMarkerTest(t *testing.T) {
const mod = `
-- go.mod --
module mod.com
go 1.12
-- main.go --
package main
var C = 3
func main() {
println(C) //@rename("C", "D")
}
-- main.go.rename_C_D_unified --
- var C = 3
+ var D = 3
- println(D) //@rename("C", "D")
+ println(D) //@rename("C", "D")
`
RunMarkerTest(t, mod, tests.Rename)
RunMarkerTest(t, mod, tests.Rename, tests.References)
RunMarkerTest(t, mod, tests.All...)
} |
Port the extraction tests, which involved a mixture of suggestedfix, extractmethod, and extractfunc markers (notably, nothing was running the extractfunc markers!). To do this, extend the new codeaction markers to accept an option slice of titles to use for filtering. Modify the method/func extraction tests to reduce verbosity and long lines. For golang/go#54845 Change-Id: I319d1c731a4cdb4ad952944667bc57d781ad176d Reviewed-on: https://go-review.googlesource.com/c/tools/+/539481 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Change https://go.dev/cl/540915 mentions this issue: |
Change https://go.dev/cl/540916 mentions this issue: |
Change https://go.dev/cl/539664 mentions this issue: |
Change https://go.dev/cl/539665 mentions this issue: |
Change https://go.dev/cl/540917 mentions this issue: |
For golang/go#54845 Change-Id: I0b7057420f6bac90161b7861630be584ad7b27ad Reviewed-on: https://go-review.googlesource.com/c/tools/+/540655 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
For golang/go#54845 Change-Id: I04e3400d5e6d53e66ae3093448f68731714553d1 Reviewed-on: https://go-review.googlesource.com/c/tools/+/539482 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
For golang/go#54845 Change-Id: Ica94e365adc2936016d55bdf11b62391e2b47b92 Reviewed-on: https://go-review.googlesource.com/c/tools/+/540915 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Use diffs rather than full file content for rename tests. Otherwise, the golden content is too verbose, particularly for tests that are about to be ported. For golang/go#54845 Change-Id: Ib378355aa85beb9027e6f82bd2063d5fac975ee7 Reviewed-on: https://go-review.googlesource.com/c/tools/+/540916 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
The unified header adds no value for these diffs. Trim for brevity and readability (in particular because the header clashes visually with the txtar file header). For golang/go#54845 Change-Id: I88223529c5520f82e6751b98aae0c1c4291b56c2 Reviewed-on: https://go-review.googlesource.com/c/tools/+/539664 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
For golang/go#54845 Change-Id: I6d5490703b50dbf944c170384f7f41311e5229bc Reviewed-on: https://go-review.googlesource.com/c/tools/+/539665 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
For golang/go#54845 Change-Id: Id6b33174392badfc216de389cc95fdc93e3bd8d0 Reviewed-on: https://go-review.googlesource.com/c/tools/+/540917 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Change https://go.dev/cl/541196 mentions this issue: |
Change https://go.dev/cl/541126 mentions this issue: |
Change https://go.dev/cl/541127 mentions this issue: |
Change https://go.dev/cl/541129 mentions this issue: |
These tests weren't actually asserting anything other than the lack of an error in the semantic tokens request (oops). Add some basic test coverage -- we also have regression tests for this feature. Notably, though, we had zero coverage of SemanticTokensRange. For golang/go#54845 Change-Id: Ib7b0df5406fbbbbb34c4a57a8d31395dd9e399d4 Reviewed-on: https://go-review.googlesource.com/c/tools/+/541196 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
I went to translate the one 'addimport' marker test to the new framework, only to decide that it would be better as a one-off regression test in ./internal/regtest/misc, only to discover that there was already a regression test misc.TestAddImport doing exactly what we want. So this coverage was completely redundant -- just remove it. For golang/go#54845 Change-Id: I1412990a9027b97b2b76c56462fe17c43c5a0c6e Reviewed-on: https://go-review.googlesource.com/c/tools/+/541126 Reviewed-by: Alan Donovan <adonovan@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
%percent and noparse are merged into a strangefiles.txt suite, with the caveat that I have no idea why they existed. We already had a placeholder port of the (disabled) nested_complit test. For golang/go#54845 Change-Id: I81fd6a9c2403a9e10380b890495a51dcf243d2d9 Reviewed-on: https://go-review.googlesource.com/c/tools/+/541127 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
For golang/go#54845 Change-Id: I289688a677fa6497035912eb2330bb3f0e963392 Reviewed-on: https://go-review.googlesource.com/c/tools/+/541129 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Robert Findley <rfindley@google.com>
Change https://go.dev/cl/541236 mentions this issue: |
We ported all these tests to a new marker framework (x/tools/gopls/internal/regtest/marker), which addresses all of the problems we identified with the old tests. |
Change https://go.dev/cl/542636 mentions this issue: |
With the old marker tests gone, it is no longer used. Updates golang/go#54845 Change-Id: If44e6f8b53286cfb66ed0422f30f1d79197a239f Reviewed-on: https://go-review.googlesource.com/c/tools/+/542636 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
This issue catalogs friction experienced with the "old" LSP "marker tests" in internal/lsp/testdata (run by internal/lsp/tests).
These tests have long been tricky to work with, and recently have caused a significant amount of friction while making changes to error messages in go/parser and go/types.
Notable problems:
summary*.txt.golden
files (depending on go version) as checksums to ensure that the expected number of tests ran. These are (by construction!) change detectors.CC @adonovan @griesemer
The text was updated successfully, but these errors were encountered: