| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package workspace |
| 6 |
|
| 7 |
import ( |
| 8 |
"testing" |
| 9 |
|
| 10 |
. "golang.org/x/tools/gopls/internal/test/integration" |
| 11 |
) |
| 12 |
|
| 13 |
func TestWorkspacePackagesExcludesVendor(t *testing.T) { |
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
const proxy = ` |
| 19 |
-- other.com/[email protected]/go.mod -- |
| 20 |
module other.com/b |
| 21 |
|
| 22 |
go 1.18 |
| 23 |
|
| 24 |
-- other.com/[email protected]/b.go -- |
| 25 |
package b |
| 26 |
|
| 27 |
type B int |
| 28 |
|
| 29 |
func _() { |
| 30 |
var V int // unused |
| 31 |
} |
| 32 |
` |
| 33 |
const src = ` |
| 34 |
-- go.mod -- |
| 35 |
module example.com/a |
| 36 |
go 1.14 |
| 37 |
require other.com/b v1.0.0 |
| 38 |
|
| 39 |
-- a.go -- |
| 40 |
package a |
| 41 |
|
| 42 |
import "other.com/b" |
| 43 |
|
| 44 |
var _ b.B |
| 45 |
|
| 46 |
` |
| 47 |
WithOptions( |
| 48 |
WriteGoSum("."), |
| 49 |
ProxyFiles(proxy), |
| 50 |
Modes(Default), |
| 51 |
).Run(t, src, func(t *testing.T, env *Env) { |
| 52 |
env.RunGoCommand("mod", "vendor") |
| 53 |
|
| 54 |
|
| 55 |
env.OpenFile("a.go") |
| 56 |
env.AfterChange( |
| 57 |
NoDiagnostics(), |
| 58 |
) |
| 59 |
loc := env.FirstDefinition(env.RegexpSearch("a.go", `b\.(B)`)) |
| 60 |
env.OpenFile(env.Sandbox.Workdir.URIToPath(loc.URI)) |
| 61 |
env.AfterChange( |
| 62 |
Diagnostics(env.AtRegexp("vendor/other.com/b/b.go", "V"), WithMessage("not used")), |
| 63 |
) |
| 64 |
}) |
| 65 |
} |