Skip to content

Commit

Permalink
cmd/govim: test introducing diagnostics in directory replaced deps (#738
Browse files Browse the repository at this point in the history
)

When using a directory 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 directory replaced dependency.
  • Loading branch information
leitzler committed Jan 30, 2020
1 parent f8cc422 commit 484c2d1
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 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,64 @@
# Test that we get diagnostics for errors in directory-replaced module requirements
#
# The scenario involves having a directory 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).

[golang.org/issues/36745] skip

# Open dependency via GoToDef
vim ex 'e main.go'
vim ex 'call cursor(6,11)'
vim ex 'GOVIMGoToDef'
vim expr 'expand(''%:p'')'
stdout '^\Q"'$WORK'/p/blah.go"\E$'

# 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 484c2d1

Please sign in to comment.