mirror of https://github.com/golang/go.git
gopls/internal/regtest: move TestMultipleModules_Warning to ./workspace
This test is really about workspace setup, not diagnostics. Move it in advance of changes to this feature. Pure code move, no other changes. Change-Id: Ib78f1fe5ce701673f5aa071f399da11f208874df Reviewed-on: https://go-review.googlesource.com/c/tools/+/421498 Reviewed-by: Suzy Mueller <suzmue@golang.org>
This commit is contained in:
parent
06d96ee8fc
commit
9b60852425
|
|
@ -1692,57 +1692,6 @@ import (
|
|||
})
|
||||
}
|
||||
|
||||
func TestMultipleModules_Warning(t *testing.T) {
|
||||
const modules = `
|
||||
-- a/go.mod --
|
||||
module a.com
|
||||
|
||||
go 1.12
|
||||
-- a/a.go --
|
||||
package a
|
||||
-- b/go.mod --
|
||||
module b.com
|
||||
|
||||
go 1.12
|
||||
-- b/b.go --
|
||||
package b
|
||||
`
|
||||
for _, go111module := range []string{"on", "auto"} {
|
||||
t.Run("GO111MODULE="+go111module, func(t *testing.T) {
|
||||
WithOptions(
|
||||
Modes(Default),
|
||||
EnvVars{"GO111MODULE": go111module},
|
||||
).Run(t, modules, func(t *testing.T, env *Env) {
|
||||
env.OpenFile("a/a.go")
|
||||
env.OpenFile("b/go.mod")
|
||||
env.Await(
|
||||
env.DiagnosticAtRegexp("a/a.go", "package a"),
|
||||
env.DiagnosticAtRegexp("b/go.mod", "module b.com"),
|
||||
OutstandingWork(lsp.WorkspaceLoadFailure, "gopls requires a module at the root of your workspace."),
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Expect no warning if GO111MODULE=auto in a directory in GOPATH.
|
||||
t.Run("GOPATH_GO111MODULE_auto", func(t *testing.T) {
|
||||
WithOptions(
|
||||
Modes(Default),
|
||||
EnvVars{"GO111MODULE": "auto"},
|
||||
InGOPATH(),
|
||||
).Run(t, modules, func(t *testing.T, env *Env) {
|
||||
env.OpenFile("a/a.go")
|
||||
env.Await(
|
||||
OnceMet(
|
||||
env.DoneWithOpen(),
|
||||
EmptyDiagnostics("a/a.go"),
|
||||
),
|
||||
NoOutstandingWork(),
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func TestNestedModules(t *testing.T) {
|
||||
const proxy = `
|
||||
-- nested.com@v1.0.0/go.mod --
|
||||
|
|
|
|||
|
|
@ -167,3 +167,54 @@ const F = named.D - 3
|
|||
env.Await(NoOutstandingDiagnostics())
|
||||
})
|
||||
}
|
||||
|
||||
func TestMultipleModules_Warning(t *testing.T) {
|
||||
const modules = `
|
||||
-- a/go.mod --
|
||||
module a.com
|
||||
|
||||
go 1.12
|
||||
-- a/a.go --
|
||||
package a
|
||||
-- b/go.mod --
|
||||
module b.com
|
||||
|
||||
go 1.12
|
||||
-- b/b.go --
|
||||
package b
|
||||
`
|
||||
for _, go111module := range []string{"on", "auto"} {
|
||||
t.Run("GO111MODULE="+go111module, func(t *testing.T) {
|
||||
WithOptions(
|
||||
Modes(Default),
|
||||
EnvVars{"GO111MODULE": go111module},
|
||||
).Run(t, modules, func(t *testing.T, env *Env) {
|
||||
env.OpenFile("a/a.go")
|
||||
env.OpenFile("b/go.mod")
|
||||
env.Await(
|
||||
env.DiagnosticAtRegexp("a/a.go", "package a"),
|
||||
env.DiagnosticAtRegexp("b/go.mod", "module b.com"),
|
||||
OutstandingWork(lsp.WorkspaceLoadFailure, "gopls requires a module at the root of your workspace."),
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// Expect no warning if GO111MODULE=auto in a directory in GOPATH.
|
||||
t.Run("GOPATH_GO111MODULE_auto", func(t *testing.T) {
|
||||
WithOptions(
|
||||
Modes(Default),
|
||||
EnvVars{"GO111MODULE": "auto"},
|
||||
InGOPATH(),
|
||||
).Run(t, modules, func(t *testing.T, env *Env) {
|
||||
env.OpenFile("a/a.go")
|
||||
env.Await(
|
||||
OnceMet(
|
||||
env.DoneWithOpen(),
|
||||
EmptyDiagnostics("a/a.go"),
|
||||
),
|
||||
NoOutstandingWork(),
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue