internal/lsp, go/packages/packagestest: support testing test files
This change allows testdata files to be *_test.go files. Change-Id: Ic771ea7c89ff2d2aabd1af8be56f9c7286da9053 Reviewed-on: https://go-review.googlesource.com/c/161317 Reviewed-by: Ian Cottrell <iancottrell@google.com>
This commit is contained in:
parent
379209517f
commit
279ab8e001
|
@ -136,6 +136,7 @@ func Export(t testing.TB, exporter Exporter, modules []Module) *Exported {
|
||||||
Dir: temp,
|
Dir: temp,
|
||||||
Env: append(os.Environ(), "GOPACKAGESDRIVER=off"),
|
Env: append(os.Environ(), "GOPACKAGESDRIVER=off"),
|
||||||
Overlay: make(map[string][]byte),
|
Overlay: make(map[string][]byte),
|
||||||
|
Tests: true,
|
||||||
},
|
},
|
||||||
Modules: modules,
|
Modules: modules,
|
||||||
temp: temp,
|
temp: temp,
|
||||||
|
|
|
@ -36,7 +36,7 @@ func testLSP(t *testing.T, exporter packagestest.Exporter) {
|
||||||
// We hardcode the expected number of test cases to ensure that all tests
|
// We hardcode the expected number of test cases to ensure that all tests
|
||||||
// are being executed. If a test is added, this number must be changed.
|
// are being executed. If a test is added, this number must be changed.
|
||||||
const expectedCompletionsCount = 63
|
const expectedCompletionsCount = 63
|
||||||
const expectedDiagnosticsCount = 13
|
const expectedDiagnosticsCount = 14
|
||||||
const expectedFormatCount = 3
|
const expectedFormatCount = 3
|
||||||
const expectedDefinitionsCount = 16
|
const expectedDefinitionsCount = 16
|
||||||
const expectedTypeDefinitionsCount = 2
|
const expectedTypeDefinitionsCount = 2
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
package testy
|
||||||
|
|
||||||
|
func a() {}
|
|
@ -0,0 +1,8 @@
|
||||||
|
package testy
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestSomething(t *testing.T) { //@item(TestSomething, "TestSomething(t *testing.T)", "", "func")
|
||||||
|
var x int //@diag("x", "x declared but not used")
|
||||||
|
a()
|
||||||
|
}
|
Loading…
Reference in New Issue