internal/lsp/regtest: only print RPC logs if asked

Sometimes one wants to run the regtests with verbose output without
seeing the wall of RPC logs. Add a new flag to control the printing of
logs, rather than overloading testing.Verbose().

Change-Id: Iea5727e3079005d229319cbf86f67067f7c1f85d
Reviewed-on: https://go-review.googlesource.com/c/tools/+/405894
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/internal/lsp/regtest/regtest.go b/internal/lsp/regtest/regtest.go
index 3180623..9ebc673 100644
--- a/internal/lsp/regtest/regtest.go
+++ b/internal/lsp/regtest/regtest.go
@@ -26,6 +26,7 @@
 	regtestTimeout           = flag.Duration("regtest_timeout", defaultRegtestTimeout(), "if nonzero, default timeout for each regtest; defaults to GOPLS_REGTEST_TIMEOUT")
 	skipCleanup              = flag.Bool("regtest_skip_cleanup", false, "whether to skip cleaning up temp directories")
 	printGoroutinesOnFailure = flag.Bool("regtest_print_goroutines", false, "whether to print goroutines info on failure")
+	printLogs                = flag.Bool("regtest_print_logs", false, "whether to print LSP logs")
 )
 
 func defaultRegtestTimeout() time.Duration {
diff --git a/internal/lsp/regtest/runner.go b/internal/lsp/regtest/runner.go
index 822a5a3..3cfeb77 100644
--- a/internal/lsp/regtest/runner.go
+++ b/internal/lsp/regtest/runner.go
@@ -313,7 +313,7 @@
 				if t.Failed() && r.PrintGoroutinesOnFailure {
 					pprof.Lookup("goroutine").WriteTo(os.Stderr, 1)
 				}
-				if t.Failed() || testing.Verbose() {
+				if t.Failed() || *printLogs {
 					ls.printBuffers(t.Name(), os.Stderr)
 				}
 				// For tests that failed due to a timeout, don't fail to shutdown