mirror of
https://github.com/golang/go
synced 2024-11-05 17:26:11 -07:00
c1702b46e6
Use the -v flag to control whether RPC logs are always printed, rather than a regtest specific flag. Updates golang/go#39130 Change-Id: Ie6293815adee4b59defd80cfc015838cfbf2b3e8 Reviewed-on: https://go-review.googlesource.com/c/tools/+/235920 Run-TryBot: Robert Findley <rfindley@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Peter Weinberger <pjw@google.com>
57 lines
1.6 KiB
Go
57 lines
1.6 KiB
Go
// Copyright 2020 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 regtest
|
|
|
|
import (
|
|
"context"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
"testing"
|
|
"time"
|
|
|
|
"golang.org/x/tools/internal/lsp/cmd"
|
|
"golang.org/x/tools/internal/tool"
|
|
)
|
|
|
|
var (
|
|
runSubprocessTests = flag.Bool("enable_gopls_subprocess_tests", false, "run regtests against a gopls subprocess")
|
|
goplsBinaryPath = flag.String("gopls_test_binary", "", "path to the gopls binary for use as a remote, for use with the -enable_gopls_subprocess_tests flag")
|
|
regtestTimeout = flag.Duration("regtest_timeout", 60*time.Second, "default timeout for each regtest")
|
|
printGoroutinesOnFailure = flag.Bool("regtest_print_goroutines", false, "whether to print goroutines info on failure")
|
|
)
|
|
|
|
var runner *Runner
|
|
|
|
func TestMain(m *testing.M) {
|
|
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: NormalModes,
|
|
Timeout: *regtestTimeout,
|
|
PrintGoroutinesOnFailure: *printGoroutinesOnFailure,
|
|
}
|
|
if *runSubprocessTests {
|
|
goplsPath := *goplsBinaryPath
|
|
if goplsPath == "" {
|
|
var err error
|
|
goplsPath, err = os.Executable()
|
|
if err != nil {
|
|
panic(fmt.Sprintf("finding test binary path: %v", err))
|
|
}
|
|
}
|
|
runner.DefaultModes = NormalModes | SeparateProcess
|
|
runner.GoplsPath = goplsPath
|
|
}
|
|
|
|
code := m.Run()
|
|
runner.Close()
|
|
os.Exit(code)
|
|
}
|