diff --git a/gopls/internal/regtest/bench/bench_test.go b/gopls/internal/regtest/bench/bench_test.go index 1702e841fe..14e6e4df78 100644 --- a/gopls/internal/regtest/bench/bench_test.go +++ b/gopls/internal/regtest/bench/bench_test.go @@ -9,13 +9,14 @@ import ( "fmt" "testing" - . "golang.org/x/tools/gopls/internal/regtest" + "golang.org/x/tools/gopls/internal/hooks" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp/protocol" ) func TestMain(m *testing.M) { - Main(m) + Main(m, hooks.Options) } func printBenchmarkResults(result testing.BenchmarkResult) { diff --git a/gopls/internal/regtest/bench/completion_bench_test.go b/gopls/internal/regtest/bench/completion_bench_test.go index be36d45ac0..c677339316 100644 --- a/gopls/internal/regtest/bench/completion_bench_test.go +++ b/gopls/internal/regtest/bench/completion_bench_test.go @@ -11,7 +11,7 @@ import ( "strings" "testing" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp/fake" ) diff --git a/gopls/internal/regtest/bench/stress_test.go b/gopls/internal/regtest/bench/stress_test.go index 8cdbcfe539..88ecbaf631 100644 --- a/gopls/internal/regtest/bench/stress_test.go +++ b/gopls/internal/regtest/bench/stress_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" ) // Pilosa is a repository that has historically caused significant memory diff --git a/gopls/internal/regtest/codelens/codelens_test.go b/gopls/internal/regtest/codelens/codelens_test.go index 87d0863823..d745ced678 100644 --- a/gopls/internal/regtest/codelens/codelens_test.go +++ b/gopls/internal/regtest/codelens/codelens_test.go @@ -10,7 +10,8 @@ import ( "testing" "time" - . "golang.org/x/tools/gopls/internal/regtest" + "golang.org/x/tools/gopls/internal/hooks" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp/command" "golang.org/x/tools/internal/lsp/fake" @@ -20,7 +21,7 @@ import ( ) func TestMain(m *testing.M) { - Main(m) + Main(m, hooks.Options) } func TestDisablingCodeLens(t *testing.T) { diff --git a/gopls/internal/regtest/completion/completion_test.go b/gopls/internal/regtest/completion/completion_test.go index 417a95f15f..798409506a 100644 --- a/gopls/internal/regtest/completion/completion_test.go +++ b/gopls/internal/regtest/completion/completion_test.go @@ -9,7 +9,8 @@ import ( "strings" "testing" - . "golang.org/x/tools/gopls/internal/regtest" + "golang.org/x/tools/gopls/internal/hooks" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp/fake" "golang.org/x/tools/internal/lsp/protocol" @@ -17,7 +18,7 @@ import ( ) func TestMain(m *testing.M) { - Main(m) + Main(m, hooks.Options) } const proxy = ` diff --git a/gopls/internal/regtest/completion/postfix_snippet_test.go b/gopls/internal/regtest/completion/postfix_snippet_test.go index 4c59ef90de..1f5b7cfc7a 100644 --- a/gopls/internal/regtest/completion/postfix_snippet_test.go +++ b/gopls/internal/regtest/completion/postfix_snippet_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp/source" ) diff --git a/gopls/internal/regtest/diagnostics/diagnostics_test.go b/gopls/internal/regtest/diagnostics/diagnostics_test.go index 3a4beee676..94b33dd4f0 100644 --- a/gopls/internal/regtest/diagnostics/diagnostics_test.go +++ b/gopls/internal/regtest/diagnostics/diagnostics_test.go @@ -10,7 +10,8 @@ import ( "log" "testing" - . "golang.org/x/tools/gopls/internal/regtest" + "golang.org/x/tools/gopls/internal/hooks" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp" "golang.org/x/tools/internal/lsp/fake" @@ -19,7 +20,7 @@ import ( ) func TestMain(m *testing.M) { - Main(m) + Main(m, hooks.Options) } // Use mod.com for all go.mod files due to golang/go#35230. diff --git a/gopls/internal/regtest/misc/configuration_test.go b/gopls/internal/regtest/misc/configuration_test.go index c71f222e1e..17116adaac 100644 --- a/gopls/internal/regtest/misc/configuration_test.go +++ b/gopls/internal/regtest/misc/configuration_test.go @@ -7,7 +7,7 @@ package misc import ( "testing" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp/fake" "golang.org/x/tools/internal/testenv" diff --git a/gopls/internal/regtest/misc/definition_test.go b/gopls/internal/regtest/misc/definition_test.go index 48b76173e9..970658c7d4 100644 --- a/gopls/internal/regtest/misc/definition_test.go +++ b/gopls/internal/regtest/misc/definition_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp/fake" "golang.org/x/tools/internal/lsp/tests" diff --git a/gopls/internal/regtest/misc/embed_test.go b/gopls/internal/regtest/misc/embed_test.go index 76d1225476..8fb654ba18 100644 --- a/gopls/internal/regtest/misc/embed_test.go +++ b/gopls/internal/regtest/misc/embed_test.go @@ -6,7 +6,7 @@ package misc import ( "testing" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/testenv" ) diff --git a/gopls/internal/regtest/misc/failures_test.go b/gopls/internal/regtest/misc/failures_test.go index 41a833ef00..23fccfd628 100644 --- a/gopls/internal/regtest/misc/failures_test.go +++ b/gopls/internal/regtest/misc/failures_test.go @@ -7,7 +7,7 @@ package misc import ( "testing" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" ) // This test passes (TestHoverOnError in definition_test.go) without diff --git a/gopls/internal/regtest/misc/fix_test.go b/gopls/internal/regtest/misc/fix_test.go index 9225a83295..8c5662adfb 100644 --- a/gopls/internal/regtest/misc/fix_test.go +++ b/gopls/internal/regtest/misc/fix_test.go @@ -7,7 +7,7 @@ package misc import ( "testing" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp/protocol" "golang.org/x/tools/internal/lsp/tests" diff --git a/gopls/internal/regtest/misc/formatting_test.go b/gopls/internal/regtest/misc/formatting_test.go index 0ad5fbb787..52d89e4ba2 100644 --- a/gopls/internal/regtest/misc/formatting_test.go +++ b/gopls/internal/regtest/misc/formatting_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp/tests" ) diff --git a/gopls/internal/regtest/misc/generate_test.go b/gopls/internal/regtest/misc/generate_test.go index a7631d9e94..6904fe0f95 100644 --- a/gopls/internal/regtest/misc/generate_test.go +++ b/gopls/internal/regtest/misc/generate_test.go @@ -12,7 +12,7 @@ package misc import ( "testing" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" ) func TestGenerateProgress(t *testing.T) { diff --git a/gopls/internal/regtest/misc/highlight_test.go b/gopls/internal/regtest/misc/highlight_test.go index 56e61161d8..affbffd66f 100644 --- a/gopls/internal/regtest/misc/highlight_test.go +++ b/gopls/internal/regtest/misc/highlight_test.go @@ -8,9 +8,9 @@ import ( "sort" "testing" - . "golang.org/x/tools/gopls/internal/regtest" "golang.org/x/tools/internal/lsp/fake" "golang.org/x/tools/internal/lsp/protocol" + . "golang.org/x/tools/internal/lsp/regtest" ) func TestWorkspacePackageHighlight(t *testing.T) { diff --git a/gopls/internal/regtest/misc/imports_test.go b/gopls/internal/regtest/misc/imports_test.go index 2a666c4e61..4ae2be6bf1 100644 --- a/gopls/internal/regtest/misc/imports_test.go +++ b/gopls/internal/regtest/misc/imports_test.go @@ -11,7 +11,7 @@ import ( "strings" "testing" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp/protocol" "golang.org/x/tools/internal/testenv" diff --git a/gopls/internal/regtest/misc/link_test.go b/gopls/internal/regtest/misc/link_test.go index 320a3eac42..daea74250f 100644 --- a/gopls/internal/regtest/misc/link_test.go +++ b/gopls/internal/regtest/misc/link_test.go @@ -8,7 +8,7 @@ import ( "strings" "testing" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/testenv" ) diff --git a/gopls/internal/regtest/misc/misc_test.go b/gopls/internal/regtest/misc/misc_test.go index 0f42470607..3694b07fc1 100644 --- a/gopls/internal/regtest/misc/misc_test.go +++ b/gopls/internal/regtest/misc/misc_test.go @@ -7,9 +7,10 @@ package misc import ( "testing" - "golang.org/x/tools/gopls/internal/regtest" + "golang.org/x/tools/gopls/internal/hooks" + "golang.org/x/tools/internal/lsp/regtest" ) func TestMain(m *testing.M) { - regtest.Main(m) + regtest.Main(m, hooks.Options) } diff --git a/gopls/internal/regtest/misc/references_test.go b/gopls/internal/regtest/misc/references_test.go index 93276362af..f3a23e436f 100644 --- a/gopls/internal/regtest/misc/references_test.go +++ b/gopls/internal/regtest/misc/references_test.go @@ -7,7 +7,7 @@ package misc import ( "testing" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" ) func TestStdlibReferences(t *testing.T) { diff --git a/gopls/internal/regtest/misc/shared_test.go b/gopls/internal/regtest/misc/shared_test.go index 376d378ae7..129a5ff3e0 100644 --- a/gopls/internal/regtest/misc/shared_test.go +++ b/gopls/internal/regtest/misc/shared_test.go @@ -7,7 +7,7 @@ package misc import ( "testing" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" ) const sharedProgram = ` diff --git a/gopls/internal/regtest/misc/vendor_test.go b/gopls/internal/regtest/misc/vendor_test.go index 1c9a4eca1f..4e02799b47 100644 --- a/gopls/internal/regtest/misc/vendor_test.go +++ b/gopls/internal/regtest/misc/vendor_test.go @@ -7,7 +7,7 @@ package misc import ( "testing" - . "golang.org/x/tools/gopls/internal/regtest" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp/protocol" "golang.org/x/tools/internal/testenv" diff --git a/gopls/internal/regtest/modfile/modfile_test.go b/gopls/internal/regtest/modfile/modfile_test.go index 33b65feb35..f59fa0b614 100644 --- a/gopls/internal/regtest/modfile/modfile_test.go +++ b/gopls/internal/regtest/modfile/modfile_test.go @@ -9,7 +9,8 @@ import ( "strings" "testing" - . "golang.org/x/tools/gopls/internal/regtest" + "golang.org/x/tools/gopls/internal/hooks" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp/protocol" "golang.org/x/tools/internal/lsp/tests" @@ -17,7 +18,7 @@ import ( ) func TestMain(m *testing.M) { - Main(m) + Main(m, hooks.Options) } const workspaceProxy = ` diff --git a/gopls/internal/regtest/watch/watch_test.go b/gopls/internal/regtest/watch/watch_test.go index 9cc9d0a22b..82a5933e72 100644 --- a/gopls/internal/regtest/watch/watch_test.go +++ b/gopls/internal/regtest/watch/watch_test.go @@ -7,7 +7,8 @@ package regtest import ( "testing" - . "golang.org/x/tools/gopls/internal/regtest" + "golang.org/x/tools/gopls/internal/hooks" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp/fake" "golang.org/x/tools/internal/lsp/protocol" @@ -15,7 +16,7 @@ import ( ) func TestMain(m *testing.M) { - Main(m) + Main(m, hooks.Options) } func TestEditFile(t *testing.T) { diff --git a/gopls/internal/regtest/workspace/workspace_test.go b/gopls/internal/regtest/workspace/workspace_test.go index 21e33b6c79..09efce3fc3 100644 --- a/gopls/internal/regtest/workspace/workspace_test.go +++ b/gopls/internal/regtest/workspace/workspace_test.go @@ -12,7 +12,8 @@ import ( "strings" "testing" - . "golang.org/x/tools/gopls/internal/regtest" + "golang.org/x/tools/gopls/internal/hooks" + . "golang.org/x/tools/internal/lsp/regtest" "golang.org/x/tools/internal/lsp/command" "golang.org/x/tools/internal/lsp/fake" @@ -21,7 +22,7 @@ import ( ) func TestMain(m *testing.M) { - Main(m) + Main(m, hooks.Options) } const workspaceProxy = ` diff --git a/gopls/internal/regtest/doc.go b/internal/lsp/regtest/doc.go similarity index 100% rename from gopls/internal/regtest/doc.go rename to internal/lsp/regtest/doc.go diff --git a/gopls/internal/regtest/env.go b/internal/lsp/regtest/env.go similarity index 100% rename from gopls/internal/regtest/env.go rename to internal/lsp/regtest/env.go diff --git a/gopls/internal/regtest/env_test.go b/internal/lsp/regtest/env_test.go similarity index 100% rename from gopls/internal/regtest/env_test.go rename to internal/lsp/regtest/env_test.go diff --git a/gopls/internal/regtest/expectation.go b/internal/lsp/regtest/expectation.go similarity index 100% rename from gopls/internal/regtest/expectation.go rename to internal/lsp/regtest/expectation.go diff --git a/gopls/internal/regtest/regtest.go b/internal/lsp/regtest/regtest.go similarity index 96% rename from gopls/internal/regtest/regtest.go rename to internal/lsp/regtest/regtest.go index 7a4fa27530..35cf3f33cb 100644 --- a/gopls/internal/regtest/regtest.go +++ b/internal/lsp/regtest/regtest.go @@ -15,6 +15,7 @@ import ( "time" "golang.org/x/tools/internal/lsp/cmd" + "golang.org/x/tools/internal/lsp/source" "golang.org/x/tools/internal/testenv" "golang.org/x/tools/internal/tool" ) @@ -83,7 +84,7 @@ func DefaultModes() Mode { } // Main sets up and tears down the shared regtest state. -func Main(m *testing.M) { +func Main(m *testing.M, hook func(*source.Options)) { testenv.ExitIfSmallMachine() flag.Parse() @@ -97,6 +98,7 @@ func Main(m *testing.M) { Timeout: *regtestTimeout, PrintGoroutinesOnFailure: *printGoroutinesOnFailure, SkipCleanup: *skipCleanup, + OptionsHook: hook, } if *runSubprocessTests { goplsPath := *goplsBinaryPath diff --git a/gopls/internal/regtest/runner.go b/internal/lsp/regtest/runner.go similarity index 99% rename from gopls/internal/regtest/runner.go rename to internal/lsp/regtest/runner.go index cfa64af540..0489af6015 100644 --- a/gopls/internal/regtest/runner.go +++ b/internal/lsp/regtest/runner.go @@ -21,7 +21,6 @@ import ( exec "golang.org/x/sys/execabs" - "golang.org/x/tools/gopls/internal/hooks" "golang.org/x/tools/internal/jsonrpc2" "golang.org/x/tools/internal/jsonrpc2/servertest" "golang.org/x/tools/internal/lsp/cache" @@ -60,6 +59,7 @@ type Runner struct { PrintGoroutinesOnFailure bool TempDir string SkipCleanup bool + OptionsHook func(*source.Options) mu sync.Mutex ts *servertest.TCPServer @@ -84,7 +84,7 @@ func (r *Runner) defaultConfig() *runConfig { return &runConfig{ modes: r.DefaultModes, timeout: r.Timeout, - optionsHook: hooks.Options, + optionsHook: r.OptionsHook, } } diff --git a/gopls/internal/regtest/wrappers.go b/internal/lsp/regtest/wrappers.go similarity index 100% rename from gopls/internal/regtest/wrappers.go rename to internal/lsp/regtest/wrappers.go