mirror of
https://github.com/golang/go
synced 2024-11-18 13:14:47 -07:00
30fd94b347
Three new flags are added to the serve command, and threaded through to the LSP forwarder: -remote.listen.timeout: -listen.timeout for the auto-started daemon -remote.debug: -debug for the auto-started daemon -remote.logfile: -logfile for the auto-started daemon As part of this change, no longer enable debugging the daemon by default. Notably none of this configuration affects serving, so modifying this configuration has been chosen not to change the path to the automatic daemon. In other words, this configuration has effect only for the forwarder process that starts the daemon: all others will connect to the daemon and inherit whatever configuration it had at startup. This should be OK, because in the common case this configuration should be static across all clients (e.g., many Vim sessions all sharing the same .vimrc). Exposing this configuration made the signature of lsprpc.NewForwarder a bit hard to understand, so I decided to go ahead and switch to a variadic options pattern for initializing both the Forwarder and StreamServer, the latter just for consistency with the Forwarder. Updates golang/go#34111 Change-Id: Iefb71e337befe08b23e451477d19fd57e69f36c6 Reviewed-on: https://go-review.googlesource.com/c/tools/+/222670 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
57 lines
1.6 KiB
Go
57 lines
1.6 KiB
Go
// Copyright 2019 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package gopls_test
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"golang.org/x/tools/go/packages/packagestest"
|
|
"golang.org/x/tools/gopls/internal/hooks"
|
|
"golang.org/x/tools/internal/jsonrpc2/servertest"
|
|
"golang.org/x/tools/internal/lsp/cache"
|
|
cmdtest "golang.org/x/tools/internal/lsp/cmd/test"
|
|
"golang.org/x/tools/internal/lsp/debug"
|
|
"golang.org/x/tools/internal/lsp/lsprpc"
|
|
"golang.org/x/tools/internal/lsp/source"
|
|
"golang.org/x/tools/internal/lsp/tests"
|
|
"golang.org/x/tools/internal/testenv"
|
|
)
|
|
|
|
func TestMain(m *testing.M) {
|
|
testenv.ExitIfSmallMachine()
|
|
os.Exit(m.Run())
|
|
}
|
|
|
|
func TestCommandLine(t *testing.T) {
|
|
packagestest.TestAll(t, testCommandLine)
|
|
}
|
|
|
|
func commandLineOptions(options *source.Options) {
|
|
options.StaticCheck = true
|
|
options.GoDiff = false
|
|
hooks.Options(options)
|
|
}
|
|
|
|
func testCommandLine(t *testing.T, exporter packagestest.Exporter) {
|
|
const testdata = "../../internal/lsp/testdata"
|
|
if stat, err := os.Stat(testdata); err != nil || !stat.IsDir() {
|
|
t.Skip("testdata directory not present")
|
|
}
|
|
data := tests.Load(t, exporter, testdata)
|
|
ctx := tests.Context(t)
|
|
ctx = debug.WithInstance(ctx, "", "")
|
|
cache := cache.New(ctx, commandLineOptions)
|
|
ss := lsprpc.NewStreamServer(cache)
|
|
ts := servertest.NewTCPServer(ctx, ss)
|
|
for _, data := range data {
|
|
defer data.Exported.Cleanup()
|
|
t.Run(data.Folder, func(t *testing.T) {
|
|
t.Helper()
|
|
tests.Run(t, cmdtest.NewRunner(exporter, data, tests.Context(t), ts.Addr, commandLineOptions), data)
|
|
})
|
|
}
|
|
}
|