Skip to content
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

testing: Completion middleware testing fails with gopls v0.5.0 #649

Closed
hyangah opened this issue Sep 15, 2020 · 3 comments
Closed

testing: Completion middleware testing fails with gopls v0.5.0 #649

hyangah opened this issue Sep 15, 2020 · 3 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@hyangah
Copy link
Contributor

hyangah commented Sep 15, 2020

kokoro CI started to fail with
1 failing

  1) Go Extension Tests With Gopls
       Completion middleware:

      AssertionError [ERR_ASSERTION]: file:///workspace/test/gopls/testfixtures/src/workspace/test.go:fmt.<> failed, unexpected filter text (got Errorf, want Formatter)
      + expected - actual

      -Errorf
      +Formatter
      
  	at Suite. (out/test/gopls/extension.test.js:197:24)
  	at Generator.next ()
  	at fulfilled (out/test/gopls/extension.test.js:5:58)
  	at processTicksAndRejections (internal/process/task_queues.js:94:5)

gopls log:

[Trace - 16:07:55.754 PM] Received notification '$/progress'.
Params: {"token":"5577006791947779410","value":{"kind":"begin","title":"Setting up workspace","message":"Loading packages..."}}
[Info  - 4:07:55 PM] 2020/09/15 16:07:55 Build info
----------
golang.org/x/tools/gopls v0.5.0
    golang.org/x/tools/gopls@v0.5.0 h1:XEmO9RylgmaXp33iGrWfCGopVYDGBmLy+KmsIsfIo8Y=
    github.com/BurntSushi/toml@v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
    github.com/google/go-cmp@v0.5.1 h1:JFrFEBb2xKufg6XkJsJr+WbKb4FQlURi5RUcBveYu9k=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.3.0 h1:RM4zey1++hCTbCVQfnWeKs9/IEsaBLA8vTkd0WVtmH4=
    golang.org/x/sync@v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA=
    golang.org/x/tools@v0.0.0-20200914163123-ea50a3c84940 h1:151ExL+g/k/wnhOqV+O1OliaTi0FR2UxQEEcpAhzzw8=
    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    honnef.co/go/tools@v0.0.1-2020.1.5 h1:nI5egYTGJakVyOryqLs1cQO5dO0ksin5XXs2pspk75k=
    mvdan.cc/gofumpt@v0.0.0-20200802201014-ab5a8192947d h1:t8TAw9WgTLghti7RYkpPmqk4JtQ3+wcP5GgZqgWeWLQ=
    mvdan.cc/xurls/v2@v2.2.0 h1:NSZPykBXJFCetGZykLAxaL6SIpvbVy/UFEniIfHAa8A=

Go info
-------
go version go1.15.2 linux/amd64
[Trace - 16:07:55.754 PM] Received request 'workspace/configuration - (2)'.
Params: {"items":[{"scopeUri":"file:///workspace/test/gopls/testfixtures/src/workspace","section":"gopls"},{"scopeUri":"file:///workspace/test/gopls/testfixtures/src/workspace","section":"gopls-workspace"}]}
[Trace - 16:07:55.761 PM] Sending response 'workspace/configuration - (2)' in 6ms.
Result: [null,null]
[Trace - 16:07:55.787 PM] Received request 'client/registerCapability - (3)'.
Params: {"registrations":[{"id":"workspace/didChangeWatchedFiles-0","method":"workspace/didChangeWatchedFiles","registerOptions":{"watchers":[{"globPattern":"**/*.{go,mod,sum}","kind":7},{"globPattern":"/workspace/test/gopls/testfixtures/src/workspace/**/*.{go,mod,sum}","kind":7}]}}]}
[Trace - 16:07:55.787 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/09/15 16:07:55 go env for /workspace/test/gopls/testfixtures/src/workspace\n(root /workspace/test/gopls/testfixtures/src/workspace)\n(valid build configuration = false)\n(build flags: [])\nGOPATH=/go\nGONOPROXY=\nGONOSUMDB=\nGO111MODULE=\nGOCACHE=/root/.cache/go-build\nGOROOT=/usr/local/go\nGOFLAGS=\nGOMOD=\nGOSUMDB=sum.golang.org\nGOINSECURE=\nGOMODCACHE=/go/pkg/mod\nGOPRIVATE=\nGOPROXY=https://proxy.golang.org,direct\n\n"}

...

[Trace - 16:07:57.845 PM] Received response 'textDocument/hover - (8)' in 380ms.
Result: {"contents":{"kind":"markdown","value":"```go\nfunc print(txt string)\n```\n\nThis is an unexported function so couldn\\'t get this comment on hover \\:\\(\nNot anymore\\!\\!\n"},"range":{"start":{"line":23,"character":1},"end":{"line":23,"character":6}}}
[Trace - 16:07:57.873 PM] Sending request 'textDocument/completion - (9)'.
Params: {"textDocument":{"uri":"file:///workspace/test/gopls/testfixtures/src/workspace/test.go"},"position":{"line":19,"character":5},"context":{"triggerKind":1}}
[Trace - 16:07:58.046 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/09/15 16:07:58 go/packages.Load\n\tsnapshot=2\n\tdirectory=/workspace/test/gopls/testfixtures/src/workspace\n\tquery=[file=/workspace/test/gopls/testfixtures/src/workspace/test.go]\n\tpackages=1\n"}
[Info  - 4:07:58 PM] 2020/09/15 16:07:58 go/packages.Load
	snapshot=2
	directory=/workspace/test/gopls/testfixtures/src/workspace
	query=[file=/workspace/test/gopls/testfixtures/src/workspace/test.go]
	packages=1
[Trace - 16:07:58.046 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/09/15 16:07:58 go/packages.Load\n\tsnapshot=2\n\tpackage_path=\"github.com/microsoft/vscode-go/gofixtures/gogetdoctestdata\"\n\tfiles=[/workspace/test/gopls/testfixtures/src/workspace/test.go]\n"}
[Info  - 4:07:58 PM] 2020/09/15 16:07:58 go/packages.Load
	snapshot=2
	package_path="github.com/microsoft/vscode-go/gofixtures/gogetdoctestdata"
	files=[/workspace/test/gopls/testfixtures/src/workspace/test.go]
[Trace - 16:07:58.071 PM] Received notification 'window/logMessage'.
Params: {"type":3,"message":"2020/09/15 16:07:58 go/packages.Load\n\tsnapshot=2\n\tdirectory=/workspace/test/gopls/testfixtures/src/workspace\n\tquery=[./... builtin]\n\tpackages=2\n"}
[Info  - 4:07:58 PM] 2020/09/15 16:07:58 go/packages.Load
	snapshot=2
	directory=/workspace/test/gopls/testfixtures/src/workspace
	query=[./... builtin]
	packages=2
[Trace - 16:07:58.145 PM] Received response 'textDocument/completion - (9)' in 271ms.
Result: {"isIncomplete":false,"items":[]}
[Trace - 16:07:58.175 PM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {"changes":[{"uri":"file:///workspace/test/gopls/testfixtures/src/workspace/test.go","type":2},{"uri":"file:///workspace/test/gopls/testfixtures/src/workspace/go.mod","type":2},{"uri":"file:///workspace/test/gopls/testfixtures/src/workspace/test.go","type":2},{"uri":"file:///workspace/test/gopls/testfixtures/src/workspace/go.mod","type":2}]}
[Trace - 16:07:58.295 PM] Sending request 'textDocument/completion - (10)'.
Params: {"textDocument":{"uri":"file:///workspace/test/gopls/testfixtures/src/workspace/test.go"},"position":{"line":19,"character":5},"context":{"triggerKind":1}}
[Trace - 16:07:58.297 PM] Received response 'textDocument/completion - (10)' in 1ms.
Result: {"isIncomplete":true,"items":[{"label":"Errorf","kind":3,"detail":"func(format string, a ...interface{}) error","documentation":"Errorf formats according to a format specifier and returns the string as a\nvalue that satisfies error.\n\nIf the format specifier includes a %w verb with an error operand,\nthe returned error will implement an Unwrap method returning the operand. It is\ninvalid to include more than one %w verb or to supply it with an operand\nthat does not implement the error interface. The %w verb is otherwise\na synonym for %v.\n","preselect":true,"sortText":"00000","filterText":"Errorf","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Errorf(${1:})"}},{"label":"Formatter","kind":8,"detail":"interface{...}","documentation":"Formatter is the interface implemented by values with a custom formatter.\nThe implementation of Format may call Sprint(f) or Fprint(f) etc.\nto generate its output.\n","sortText":"00001","filterText":"Formatter","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Formatter"}},{"label":"Fprint","kind":3,"detail":"func(w io.Writer, a ...interface{}) (n int, err error)","documentation":"Fprint formats using the default formats for its operands and writes to w.\nSpaces are added between operands when neither is a string.\nIt returns the number of bytes written and any write error encountered.\n","sortText":"00002","filterText":"Fprint","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Fprint(${1:})"}},{"label":"Fprintf","kind":3,"detail":"func(w io.Writer, format string, a ...interface{}) (n int, err error)","documentation":"Fprintf formats according to a format specifier and writes to w.\nIt returns the number of bytes written and any write error encountered.\n","sortText":"00003","filterText":"Fprintf","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Fprintf(${1:})"}},{"label":"Fprintln","kind":3,"detail":"func(w io.Writer, a ...interface{}) (n int, err error)","documentation":"Fprintln formats using the default formats for its operands and writes to w.\nSpaces are always added between operands and a newline is appended.\nIt returns the number of bytes written and any write error encountered.\n","sortText":"00004","filterText":"Fprintln","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Fprintln(${1:})"}},{"label":"Fscan","kind":3,"detail":"func(r io.Reader, a ...interface{}) (n int, err error)","documentation":"Fscan scans text read from r, storing successive space-separated\nvalues into successive arguments. Newlines count as space. It\nreturns the number of items successfully scanned. If that is less\nthan the number of arguments, err will report why.\n","sortText":"00005","filterText":"Fscan","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Fscan(${1:})"}},{"label":"Fscanf","kind":3,"detail":"func(r io.Reader, format string, a ...interface{}) (n int, err error)","documentation":"Fscanf scans text read from r, storing successive space-separated\nvalues into successive arguments as determined by the format. It\nreturns the number of items successfully parsed.\nNewlines in the input must match newlines in the format.\n","sortText":"00006","filterText":"Fscanf","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Fscanf(${1:})"}},{"label":"Fscanln","kind":3,"detail":"func(r io.Reader, a ...interface{}) (n int, err error)","documentation":"Fscanln is similar to Fscan, but stops scanning at a newline and\nafter the final item there must be a newline or EOF.\n","sortText":"00007","filterText":"Fscanln","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Fscanln(${1:})"}},{"label":"GoStringer","kind":8,"detail":"interface{...}","documentation":"GoStringer is implemented by any value that has a GoString method,\nwhich defines the Go syntax for that value.\nThe GoString method is used to print values passed as an operand\nto a %#v format.\n","sortText":"00008","filterText":"GoStringer","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"GoStringer"}},{"label":"Print","kind":3,"detail":"func(a ...interface{}) (n int, err error)","documentation":"Print formats using the default formats for its operands and writes to standard output.\nSpaces are added between operands when neither is a string.\nIt returns the number of bytes written and any write error encountered.\n","sortText":"00009","filterText":"Print","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Print(${1:})"}},{"label":"Printf","kind":3,"detail":"func(format string, a ...interface{}) (n int, err error)","documentation":"Printf formats according to a format specifier and writes to standard output.\nIt returns the number of bytes written and any write error encountered.\n","sortText":"00010","filterText":"Printf","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Printf(${1:})"}},{"label":"Println","kind":3,"detail":"func(a ...interface{}) (n int, err error)","documentation":"Println formats using the default formats for its operands and writes to standard output.\nSpaces are always added between operands and a newline is appended.\nIt returns the number of bytes written and any write error encountered.\n","sortText":"00011","filterText":"Println","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Println(${1:})"}},{"label":"Scan","kind":3,"detail":"func(a ...interface{}) (n int, err error)","documentation":"Scan scans text read from standard input, storing successive\nspace-separated values into successive arguments. Newlines count\nas space. It returns the number of items successfully scanned.\nIf that is less than the number of arguments, err will report why.\n","sortText":"00012","filterText":"Scan","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Scan(${1:})"}},{"label":"ScanState","kind":8,"detail":"interface{...}","documentation":"ScanState represents the scanner state passed to custom scanners.\nScanners may do rune-at-a-time scanning or ask the ScanState\nto discover the next space-delimited token.\n","sortText":"00013","filterText":"ScanState","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"ScanState"}},{"label":"Scanf","kind":3,"detail":"func(format string, a ...interface{}) (n int, err error)","documentation":"Scanf scans text read from standard input, storing successive\nspace-separated values into successive arguments as determined by\nthe format. It returns the number of items successfully scanned.\nIf that is less than the number of arguments, err will report why.\nNewlines in the input must match newlines in the format.\nThe one exception: the verb %c always scans the next rune in the\ninput, even if it is a space (or tab etc.) or newline.\n","sortText":"00014","filterText":"Scanf","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Scanf(${1:})"}},{"label":"Scanln","kind":3,"detail":"func(a ...interface{}) (n int, err error)","documentation":"Scanln is similar to Scan, but stops scanning at a newline and\nafter the final item there must be a newline or EOF.\n","sortText":"00015","filterText":"Scanln","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Scanln(${1:})"}},{"label":"Scanner","kind":8,"detail":"interface{...}","documentation":"Scanner is implemented by any value that has a Scan method, which scans\nthe input for the representation of a value and stores the result in the\nreceiver, which must be a pointer to be useful. The Scan method is called\nfor any argument to Scan, Scanf, or Scanln that implements it.\n","sortText":"00016","filterText":"Scanner","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Scanner"}},{"label":"Sprint","kind":3,"detail":"func(a ...interface{}) string","documentation":"Sprint formats using the default formats for its operands and returns the resulting string.\nSpaces are added between operands when neither is a string.\n","sortText":"00017","filterText":"Sprint","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Sprint(${1:})"}},{"label":"Sprintf","kind":3,"detail":"func(format string, a ...interface{}) string","documentation":"Sprintf formats according to a format specifier and returns the resulting string.\n","sortText":"00018","filterText":"Sprintf","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Sprintf(${1:})"}},{"label":"Sprintln","kind":3,"detail":"func(a ...interface{}) string","documentation":"Sprintln formats using the default formats for its operands and returns the resulting string.\nSpaces are always added between operands and a newline is appended.\n","sortText":"00019","filterText":"Sprintln","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Sprintln(${1:})"}},{"label":"Sscan","kind":3,"detail":"func(str string, a ...interface{}) (n int, err error)","documentation":"Sscan scans the argument string, storing successive space-separated\nvalues into successive arguments. Newlines count as space. It\nreturns the number of items successfully scanned. If that is less\nthan the number of arguments, err will report why.\n","sortText":"00020","filterText":"Sscan","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Sscan(${1:})"}},{"label":"Sscanf","kind":3,"detail":"func(str string, format string, a ...interface{}) (n int, err error)","documentation":"Sscanf scans the argument string, storing successive space-separated\nvalues into successive arguments as determined by the format. It\nreturns the number of items successfully parsed.\nNewlines in the input must match newlines in the format.\n","sortText":"00021","filterText":"Sscanf","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Sscanf(${1:})"}},{"label":"Sscanln","kind":3,"detail":"func(str string, a ...interface{}) (n int, err error)","documentation":"Sscanln is similar to Sscan, but stops scanning at a newline and\nafter the final item there must be a newline or EOF.\n","sortText":"00022","filterText":"Sscanln","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Sscanln(${1:})"}},{"label":"State","kind":8,"detail":"interface{...}","documentation":"State represents the printer state passed to custom formatters.\nIt provides access to the io.Writer interface plus information about\nthe flags and options for the operand's format specifier.\n","sortText":"00023","filterText":"State","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"State"}},{"label":"Stringer","kind":8,"detail":"interface{...}","documentation":"Stringer is implemented by any value that has a String method,\nwhich defines the ``native'' format for that value.\nThe String method is used to print values passed as an operand\nto any format that accepts a string or to an unformatted printer\nsuch as Print.\n","sortText":"00024","filterText":"Stringer","insertTextFormat":2,"textEdit":{"range":{"start":{"line":19,"character":5},"end":{"line":19,"character":5}},"newText":"Stringer"}}]}
@hyangah
Copy link
Contributor Author

hyangah commented Sep 15, 2020

cc @stamblerre

@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/255119 mentions this issue: test/gopls: fix completion middleware test

@hyangah hyangah added this to the v0.17.0 milestone Sep 16, 2020
@hyangah hyangah added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 16, 2020
@gopherbot
Copy link
Collaborator

Change https://golang.org/cl/255120 mentions this issue: [release] test/gopls: fix completion middleware test

gopherbot pushed a commit that referenced this issue Sep 16, 2020
gopls v0.5.0 seems to change the completion result ranking, so
the test that checked a specific entry for the most plausible
result is broken.  This CL made the test use a more specific
query (fmt.P<> instead of fmt.<>) so the test can pass with
gopls 0.4.x and 0.5.0.

Probably, it's better to just check whether the desirable entry
is in one of the top k results where k is a reasonablly small
but larger than 1. I don't know what's a good number yet.

Fixes #649

Change-Id: I805b2f1b2c4ae6dde19f6a931434b46fb0954510
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/255119
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rebecca Stambler <rstambler@golang.org>
(cherry picked from commit 5879a3e)
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/255120
@golang golang locked and limited conversation to collaborators Sep 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants