Skip to content

Commit

Permalink
cmd/govim: test introducing diagnostics in locally replaced dependencies
Browse files Browse the repository at this point in the history
When using a locally replaced dependency it isn't monitored by gopls,
see https://golang.org/issues/36745.

This change adds a test that verifies that we do get diagnostics from
gopls when introducing errors in a replaced dependency.
  • Loading branch information
leitzler committed Jan 29, 2020
1 parent 01c8f58 commit ac57a5d
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions cmd/govim/testdata/scenario_default/quickfix_replaced_dep.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Test that we get diagnostics for edits in a locally replaced dependency
#
# The scenario involves having a locally replaced dependency in go.mod.
# When there is an error introduced into the local copy it should produce
# a diagnostic (see https://golang.org/issues/36745).

skip 'Pending fix for golang.org/issues/36745'

# Open dependency via GoToDef
vim ex 'e main.go'
vim ex 'call cursor(6,11)'
vim ex 'GOVIMGoToDef'
errlogmatch '&protocol\.DidOpenTextDocumentParams\{\n\S+:\s+TextDocument: protocol.TextDocumentItem{URI:"file://'$WORK/p/blah.go

# Add some nonsense to introduce a compile error
vim call append '[3, "asd"]'

# Expect the error to be reported
vimexprwait error.golden GOVIMTest_getqflist()

# Assert that we have received no error (Type: 1) or warning (Type: 2) log messages
# Disabled pending resolution to https://github.com/golang/go/issues/34103
# errlogmatch -start -count=0 'LogMessage callback: &protocol\.LogMessageParams\{Type:(1|2), Message:".*'

-- go.mod --
module a

go 1.12

replace example.com/blah => ./p

require example.com/blah v1.0.0
-- main.go --
package main

import "example.com/blah"

func main() {
_ = blah.Name
}
-- p/go.mod --
module example.com/blah

go 1.12
-- p/blah.go --
package blah

const Name = "example.com/blah"
-- error.golden --
[
{
"bufname": "p/blah.go",
"col": 1,
"lnum": 4,
"module": "",
"nr": 0,
"pattern": "",
"text": "expected declaration, found asd",
"type": "",
"valid": 1,
"vcol": 0
}
]

0 comments on commit ac57a5d

Please sign in to comment.