Skip to content

Commit

Permalink
gopls/internal/regtest: eliminate GoSumDiagnostic
Browse files Browse the repository at this point in the history
Remove the redundant GoSumDiagnostic.

Updates golang/go#39384

Change-Id: I742fbe5d32dd55288c7632bed335f0d33e1015d5
Reviewed-on: https://go-review.googlesource.com/c/tools/+/461916
gopls-CI: kokoro <noreply+kokoro@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
  • Loading branch information
findleyr committed Jan 13, 2023
1 parent 331a1c6 commit ab7b5b2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
17 changes: 0 additions & 17 deletions gopls/internal/lsp/regtest/expectation.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"golang.org/x/tools/gopls/internal/lsp"
"golang.org/x/tools/gopls/internal/lsp/fake"
"golang.org/x/tools/gopls/internal/lsp/protocol"
"golang.org/x/tools/internal/testenv"
)

// An Expectation asserts that the state of the editor at a point in time
Expand Down Expand Up @@ -875,19 +874,3 @@ func (e *Env) DiagnosticAtRegexpWithMessage(name, re, msg string) DiagnosticExpe
func DiagnosticAt(name string, line, col int) DiagnosticExpectation {
return DiagnosticExpectation{path: name, pos: &fake.Pos{Line: line, Column: col}, present: true}
}

// GoSumDiagnostic asserts that a "go.sum is out of sync" diagnostic for the
// given module (as formatted in a go.mod file, e.g. "example.com v1.0.0") is
// present.
//
// TODO(rfindley): remove this.
func (e *Env) GoSumDiagnostic(name, module string) Expectation {
e.T.Helper()
// In 1.16, go.sum diagnostics should appear on the relevant module. Earlier
// errors have no information and appear on the module declaration.
if testenv.Go1Point() >= 16 {
return e.DiagnosticAtRegexpWithMessage(name, module, "go.sum is out of sync")
} else {
return e.DiagnosticAtRegexpWithMessage(name, `module`, "go.sum is out of sync")
}
}
10 changes: 8 additions & 2 deletions gopls/internal/regtest/modfile/modfile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,10 @@ func main() {
d := &protocol.PublishDiagnosticsParams{}
env.OpenFile("go.mod")
env.AfterChange(
env.GoSumDiagnostic("go.mod", `example.com v1.2.3`),
Diagnostics(
env.AtRegexp("go.mod", `example.com v1.2.3`),
WithMessageContaining("go.sum is out of sync"),
),
ReadDiagnostics("go.mod", d),
)
env.ApplyQuickFixes("go.mod", d.Diagnostics)
Expand Down Expand Up @@ -1098,7 +1101,10 @@ func main() {
params := &protocol.PublishDiagnosticsParams{}
env.Await(
OnceMet(
env.GoSumDiagnostic("go.mod", "example.com"),
Diagnostics(
env.AtRegexp("go.mod", `example.com`),
WithMessageContaining("go.sum is out of sync"),
),
ReadDiagnostics("go.mod", params),
),
)
Expand Down
5 changes: 4 additions & 1 deletion gopls/internal/regtest/workspace/workspace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,10 @@ func main() {
params := &protocol.PublishDiagnosticsParams{}
env.OpenFile("b/go.mod")
env.AfterChange(
env.GoSumDiagnostic("b/go.mod", `example.com v1.2.3`),
Diagnostics(
env.AtRegexp("go.mod", `example.com v1.2.3`),
WithMessageContaining("go.sum is out of sync"),
),
ReadDiagnostics("b/go.mod", params),
)
for _, d := range params.Diagnostics {
Expand Down

0 comments on commit ab7b5b2

Please sign in to comment.