Skip to content

Commit

Permalink
gopls/internal/lsp: suppress noisy log output in tests
Browse files Browse the repository at this point in the history
Disable logging for lsp tests: logs are not scoped to the failing test
and are therefore misleading.

For golang/go#54845

Change-Id: I232e4cfc114382121923e8e697452007793ec3c9
Reviewed-on: https://go-review.googlesource.com/c/tools/+/431843
gopls-CI: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
  • Loading branch information
findleyr committed Sep 20, 2022
1 parent df2eb93 commit f901623
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions gopls/internal/lsp/lsp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,30 @@ import (
"strings"
"testing"

"golang.org/x/tools/internal/bug"
"golang.org/x/tools/gopls/internal/lsp/cache"
"golang.org/x/tools/gopls/internal/lsp/command"
"golang.org/x/tools/internal/diff"
"golang.org/x/tools/gopls/internal/lsp/protocol"
"golang.org/x/tools/gopls/internal/lsp/source"
"golang.org/x/tools/gopls/internal/lsp/tests"
"golang.org/x/tools/gopls/internal/lsp/tests/compare"
"golang.org/x/tools/internal/bug"
"golang.org/x/tools/internal/diff"
"golang.org/x/tools/internal/event"
"golang.org/x/tools/internal/span"
"golang.org/x/tools/internal/testenv"
)

func TestMain(m *testing.M) {
bug.PanicOnBugs = true
testenv.ExitIfSmallMachine()

// Set the global exporter to nil so that we don't log to stderr. This avoids
// a lot of misleading noise in test output.
//
// TODO(rfindley): investigate whether we can/should capture logs scoped to
// individual tests by passing in a context with a local exporter.
event.SetExporter(nil)

os.Exit(m.Run())
}

Expand Down

0 comments on commit f901623

Please sign in to comment.