gopls/test: fix erroneously skipped tests, remove redundant cmd tests

When code was moved to the golang.org/x/tools/gopls module, the
gopls/test package tests we silently skipped, because of logic that
skipped the tests if the testdata directory was not found. Narrow that
check to only skip tests on android, which is where we expect testdata
to be missing.

Also, now that gopls code lives in the gopls module, there is little
reason to have two copies of the command-line tests. Delete
gopls/internal/lsp/cmd/cmd_test.go.

Change-Id: I6d57244dd77a983b1f83c1cf653d5345e4fa0434
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431842
Run-TryBot: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
This commit is contained in:
Robert Findley 2022-09-19 17:38:47 -04:00
parent 1578244678
commit df2eb9381f
3 changed files with 5 additions and 29 deletions

View File

@ -1,25 +0,0 @@
// 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 cmd_test
import (
"os"
"testing"
"golang.org/x/tools/internal/bug"
cmdtest "golang.org/x/tools/gopls/internal/lsp/cmd/test"
"golang.org/x/tools/gopls/internal/lsp/tests"
"golang.org/x/tools/internal/testenv"
)
func TestMain(m *testing.M) {
bug.PanicOnBugs = true
testenv.ExitIfSmallMachine()
os.Exit(m.Run())
}
func TestCommandLine(t *testing.T) {
cmdtest.TestCommandLine(t, "../testdata", tests.DefaultOptions)
}

View File

@ -12,10 +12,10 @@ import (
"fmt"
"io"
"os"
"runtime"
"sync"
"testing"
"golang.org/x/tools/internal/jsonrpc2/servertest"
"golang.org/x/tools/gopls/internal/lsp/cache"
"golang.org/x/tools/gopls/internal/lsp/cmd"
"golang.org/x/tools/gopls/internal/lsp/debug"
@ -23,6 +23,7 @@ import (
"golang.org/x/tools/gopls/internal/lsp/protocol"
"golang.org/x/tools/gopls/internal/lsp/source"
"golang.org/x/tools/gopls/internal/lsp/tests"
"golang.org/x/tools/internal/jsonrpc2/servertest"
"golang.org/x/tools/internal/span"
"golang.org/x/tools/internal/tool"
)
@ -37,8 +38,8 @@ type runner struct {
func TestCommandLine(t *testing.T, testdata string, options func(*source.Options)) {
// On Android, the testdata directory is not copied to the runner.
if stat, err := os.Stat(testdata); err != nil || !stat.IsDir() {
t.Skip("testdata directory not present")
if runtime.GOOS == "android" {
t.Skip("testdata directory not present on android")
}
tests.RunTests(t, testdata, false, func(t *testing.T, datum *tests.Data) {
ctx := tests.Context(t)

View File

@ -23,7 +23,7 @@ func TestMain(m *testing.M) {
}
func TestCommandLine(t *testing.T) {
cmdtest.TestCommandLine(t, "../../internal/lsp/testdata", commandLineOptions)
cmdtest.TestCommandLine(t, "../internal/lsp/testdata", commandLineOptions)
}
func commandLineOptions(options *source.Options) {