From 9b608524258a803e0ea4326a871a2d35b198a4e6 Mon Sep 17 00:00:00 2001 From: Robert Findley Date: Thu, 4 Aug 2022 16:19:07 -0400 Subject: [PATCH] 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 --- .../regtest/diagnostics/diagnostics_test.go | 51 ------------------- .../internal/regtest/workspace/broken_test.go | 51 +++++++++++++++++++ 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/gopls/internal/regtest/diagnostics/diagnostics_test.go b/gopls/internal/regtest/diagnostics/diagnostics_test.go index d7246ae7df..b377668e87 100644 --- a/gopls/internal/regtest/diagnostics/diagnostics_test.go +++ b/gopls/internal/regtest/diagnostics/diagnostics_test.go @@ -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 -- diff --git a/gopls/internal/regtest/workspace/broken_test.go b/gopls/internal/regtest/workspace/broken_test.go index e88b98b50e..c4ac905bd0 100644 --- a/gopls/internal/regtest/workspace/broken_test.go +++ b/gopls/internal/regtest/workspace/broken_test.go @@ -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(), + ) + }) + }) +}