internal/lsp: do not treat failed go test commands as errors

The "go test" command invoked via code action/code lens performs a
ShowMessage callback to the client when the test is done.

Previously it did set severity to "Error" when the test failed, but a
failing test isn't a error condition per se. This changes the result to
be of severity Info for both successful and failed test invocations.

Change-Id: Ib76558d98a434c706823617b9901a88e53864319
Reviewed-on: https://go-review.googlesource.com/c/tools/+/269257
Run-TryBot: Pontus Leitzler <leitzler@gmail.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
Pontus Leitzler 2020-11-11 13:12:26 +01:00 committed by Robert Findley
parent 7099162a90
commit 69daaf961d
1 changed files with 1 additions and 3 deletions

View File

@ -355,14 +355,12 @@ func (s *Server) runTests(ctx context.Context, snapshot source.Snapshot, uri pro
} else if failedBenchmarks > 0 {
message = fmt.Sprintf("%d / %d benchmarks failed", failedBenchmarks, len(benchmarks))
}
messageType := protocol.Info
if failedTests > 0 || failedBenchmarks > 0 {
messageType = protocol.Error
message += "\n" + buf.String()
}
return s.client.ShowMessage(ctx, &protocol.ShowMessageParams{
Type: messageType,
Type: protocol.Info,
Message: message,
})
}