mirror of
https://github.com/golang/go
synced 2024-11-18 17:04:41 -07:00
internal/lsp: fix data race in cmd tests
fixes golang/go#33392 Change-Id: I442bf8c04d793e06631a1a9d6c905cb2dcd284b8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/189944 Run-TryBot: Ian Cottrell <iancottrell@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rebecca Stambler <rstambler@golang.org>
This commit is contained in:
parent
afc3694995
commit
528a2984e2
@ -9,6 +9,7 @@ import (
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"golang.org/x/tools/internal/lsp/cmd"
|
||||
"golang.org/x/tools/internal/lsp/tests"
|
||||
"golang.org/x/tools/internal/span"
|
||||
"golang.org/x/tools/internal/tool"
|
||||
@ -21,8 +22,9 @@ func (r *runner) Diagnostics(t *testing.T, data tests.Diagnostics) {
|
||||
}
|
||||
fname := uri.Filename()
|
||||
args := []string{"-remote=internal", "check", fname}
|
||||
app := cmd.New("gopls-test", r.data.Config.Dir, r.data.Exported.Config.Env)
|
||||
out := captureStdOut(t, func() {
|
||||
tool.Main(r.ctx, r.app, args)
|
||||
tool.Main(r.ctx, app, args)
|
||||
})
|
||||
// parse got into a collection of reports
|
||||
got := map[string]struct{}{}
|
||||
|
@ -15,14 +15,12 @@ import (
|
||||
"testing"
|
||||
|
||||
"golang.org/x/tools/go/packages/packagestest"
|
||||
"golang.org/x/tools/internal/lsp/cmd"
|
||||
"golang.org/x/tools/internal/lsp/tests"
|
||||
)
|
||||
|
||||
type runner struct {
|
||||
exporter packagestest.Exporter
|
||||
data *tests.Data
|
||||
app *cmd.Application
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
@ -37,7 +35,6 @@ func testCommandLine(t *testing.T, exporter packagestest.Exporter) {
|
||||
r := &runner{
|
||||
exporter: exporter,
|
||||
data: data,
|
||||
app: cmd.New("gopls-test", data.Config.Dir, data.Exported.Config.Env),
|
||||
ctx: tests.Context(t),
|
||||
}
|
||||
tests.Run(t, r, data)
|
||||
|
@ -83,7 +83,8 @@ func (r *runner) Definition(t *testing.T, data tests.Definitions) {
|
||||
uri := d.Src.URI()
|
||||
args = append(args, fmt.Sprint(d.Src))
|
||||
got := captureStdOut(t, func() {
|
||||
tool.Main(r.ctx, r.app, args)
|
||||
app := cmd.New("gopls-test", r.data.Config.Dir, r.data.Exported.Config.Env)
|
||||
tool.Main(r.ctx, app, args)
|
||||
})
|
||||
got = normalizePaths(r.data, got)
|
||||
if mode&jsonGoDef != 0 && runtime.GOOS == "windows" {
|
||||
|
Loading…
Reference in New Issue
Block a user