internal/lsp/regtest: print RPC logs when verbose output is enabled
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>
diff --git a/internal/lsp/regtest/reg_test.go b/internal/lsp/regtest/reg_test.go
index abd4925..9f0e283 100644
--- a/internal/lsp/regtest/reg_test.go
+++ b/internal/lsp/regtest/reg_test.go
@@ -18,10 +18,9 @@
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 -gopls_subprocess_testmode flag")
- alwaysPrintLogs = flag.Bool("regtest_print_rpc_logs", false, "whether to always print RPC logs")
+ 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 goroutine info on failure")
+ printGoroutinesOnFailure = flag.Bool("regtest_print_goroutines", false, "whether to print goroutines info on failure")
)
var runner *Runner
@@ -36,7 +35,6 @@
runner = &Runner{
DefaultModes: NormalModes,
Timeout: *regtestTimeout,
- AlwaysPrintLogs: *alwaysPrintLogs,
PrintGoroutinesOnFailure: *printGoroutinesOnFailure,
}
if *runSubprocessTests {
diff --git a/internal/lsp/regtest/runner.go b/internal/lsp/regtest/runner.go
index 95bdda4..01e05c3 100644
--- a/internal/lsp/regtest/runner.go
+++ b/internal/lsp/regtest/runner.go
@@ -55,7 +55,6 @@
DefaultModes Mode
Timeout time.Duration
GoplsPath string
- AlwaysPrintLogs bool
PrintGoroutinesOnFailure bool
mu sync.Mutex
@@ -194,7 +193,7 @@
if t.Failed() && r.PrintGoroutinesOnFailure {
pprof.Lookup("goroutine").WriteTo(os.Stderr, 1)
}
- if t.Failed() || r.AlwaysPrintLogs {
+ if t.Failed() || testing.Verbose() {
ls.printBuffers(t.Name(), os.Stderr)
}
env.CloseEditor()