Skip to content

Commit 9ed98fa

Browse files
committed
gopls/internal/test: option to suppress LSP logs on failure
Adds a RunOption NoLogsOnFailure() to suppress the printing of the voluminous LSP logs when there is a test failure. While debugging tests these logs can be a noisy distraction. Change-Id: I41379fdcef8ba00f8b8a49ec89d8795274797888 Reviewed-on: https://go-review.googlesource.com/c/tools/+/574035 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
1 parent 867c912 commit 9ed98fa

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

gopls/internal/test/integration/options.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import (
1010
)
1111

1212
type runConfig struct {
13-
editor fake.EditorConfig
14-
sandbox fake.SandboxConfig
15-
modes Mode
13+
editor fake.EditorConfig
14+
sandbox fake.SandboxConfig
15+
modes Mode
16+
noLogsOnError bool
1617
}
1718

1819
func defaultConfig() runConfig {
@@ -59,6 +60,13 @@ func Modes(modes Mode) RunOption {
5960
})
6061
}
6162

63+
// NoLogsOnError turns off dumping the LSP logs on test failures.
64+
func NoLogsOnError() RunOption {
65+
return optionSetter(func(opts *runConfig) {
66+
opts.noLogsOnError = true
67+
})
68+
}
69+
6270
// WindowsLineEndings configures the editor to use windows line endings.
6371
func WindowsLineEndings() RunOption {
6472
return optionSetter(func(opts *runConfig) {

gopls/internal/test/integration/runner.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func (r *Runner) Run(t *testing.T, files string, test TestFunc, opts ...RunOptio
235235
if t.Failed() && r.PrintGoroutinesOnFailure {
236236
pprof.Lookup("goroutine").WriteTo(os.Stderr, 1)
237237
}
238-
if t.Failed() || *printLogs {
238+
if (t.Failed() && !config.noLogsOnError) || *printLogs {
239239
ls.printBuffers(t.Name(), os.Stderr)
240240
}
241241
// For tests that failed due to a timeout, don't fail to shutdown

0 commit comments

Comments
 (0)