mirror of https://github.com/golang/go.git
internal/lsp/regtest: minor cleanup for magic regtest envvar
For some reason, we were not reusing the constant runTestAsGoplsEnvVar in the regtest Main function. Fix this, add a bit more commentary, and check the envvar before doing anything else. Also fix the threading of hooks to the created gopls server. Tested manually via -enable_gopls_subprocess_tests. Change-Id: Ieb5329aa5850e845f4d9e3868703bfa16387bce3 Reviewed-on: https://go-review.googlesource.com/c/tools/+/420716 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Robert Findley <rfindley@google.com> gopls-CI: kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
310ea71b71
commit
4d0b383458
|
|
@ -94,16 +94,19 @@ func DefaultModes() Mode {
|
|||
|
||||
// Main sets up and tears down the shared regtest state.
|
||||
func Main(m *testing.M, hook func(*source.Options)) {
|
||||
// If this magic environment variable is set, run gopls instead of the test
|
||||
// suite. See the documentation for runTestAsGoplsEnvvar for more details.
|
||||
if os.Getenv(runTestAsGoplsEnvvar) == "true" {
|
||||
tool.Main(context.Background(), cmd.New("gopls", "", nil, hook), os.Args[1:])
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
testenv.ExitIfSmallMachine()
|
||||
|
||||
// Disable GOPACKAGESDRIVER, as it can cause spurious test failures.
|
||||
os.Setenv("GOPACKAGESDRIVER", "off")
|
||||
|
||||
flag.Parse()
|
||||
if os.Getenv("_GOPLS_TEST_BINARY_RUN_AS_GOPLS") == "true" {
|
||||
tool.Main(context.Background(), cmd.New("gopls", "", nil, nil), os.Args[1:])
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
runner = &Runner{
|
||||
DefaultModes: DefaultModes(),
|
||||
|
|
|
|||
Loading…
Reference in New Issue