Skip to content

Commit ab7b5b2

Browse files
committed
gopls/internal/regtest: eliminate GoSumDiagnostic
Remove the redundant GoSumDiagnostic. Updates golang/go#39384 Change-Id: I742fbe5d32dd55288c7632bed335f0d33e1015d5 Reviewed-on: https://go-review.googlesource.com/c/tools/+/461916 gopls-CI: kokoro <[email protected]> Run-TryBot: Robert Findley <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Alan Donovan <[email protected]>
1 parent 331a1c6 commit ab7b5b2

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

gopls/internal/lsp/regtest/expectation.go

-17
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"golang.org/x/tools/gopls/internal/lsp"
1414
"golang.org/x/tools/gopls/internal/lsp/fake"
1515
"golang.org/x/tools/gopls/internal/lsp/protocol"
16-
"golang.org/x/tools/internal/testenv"
1716
)
1817

1918
// An Expectation asserts that the state of the editor at a point in time
@@ -875,19 +874,3 @@ func (e *Env) DiagnosticAtRegexpWithMessage(name, re, msg string) DiagnosticExpe
875874
func DiagnosticAt(name string, line, col int) DiagnosticExpectation {
876875
return DiagnosticExpectation{path: name, pos: &fake.Pos{Line: line, Column: col}, present: true}
877876
}
878-
879-
// GoSumDiagnostic asserts that a "go.sum is out of sync" diagnostic for the
880-
// given module (as formatted in a go.mod file, e.g. "example.com v1.0.0") is
881-
// present.
882-
//
883-
// TODO(rfindley): remove this.
884-
func (e *Env) GoSumDiagnostic(name, module string) Expectation {
885-
e.T.Helper()
886-
// In 1.16, go.sum diagnostics should appear on the relevant module. Earlier
887-
// errors have no information and appear on the module declaration.
888-
if testenv.Go1Point() >= 16 {
889-
return e.DiagnosticAtRegexpWithMessage(name, module, "go.sum is out of sync")
890-
} else {
891-
return e.DiagnosticAtRegexpWithMessage(name, `module`, "go.sum is out of sync")
892-
}
893-
}

gopls/internal/regtest/modfile/modfile_test.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,10 @@ func main() {
893893
d := &protocol.PublishDiagnosticsParams{}
894894
env.OpenFile("go.mod")
895895
env.AfterChange(
896-
env.GoSumDiagnostic("go.mod", `example.com v1.2.3`),
896+
Diagnostics(
897+
env.AtRegexp("go.mod", `example.com v1.2.3`),
898+
WithMessageContaining("go.sum is out of sync"),
899+
),
897900
ReadDiagnostics("go.mod", d),
898901
)
899902
env.ApplyQuickFixes("go.mod", d.Diagnostics)
@@ -1098,7 +1101,10 @@ func main() {
10981101
params := &protocol.PublishDiagnosticsParams{}
10991102
env.Await(
11001103
OnceMet(
1101-
env.GoSumDiagnostic("go.mod", "example.com"),
1104+
Diagnostics(
1105+
env.AtRegexp("go.mod", `example.com`),
1106+
WithMessageContaining("go.sum is out of sync"),
1107+
),
11021108
ReadDiagnostics("go.mod", params),
11031109
),
11041110
)

gopls/internal/regtest/workspace/workspace_test.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,10 @@ func main() {
972972
params := &protocol.PublishDiagnosticsParams{}
973973
env.OpenFile("b/go.mod")
974974
env.AfterChange(
975-
env.GoSumDiagnostic("b/go.mod", `example.com v1.2.3`),
975+
Diagnostics(
976+
env.AtRegexp("go.mod", `example.com v1.2.3`),
977+
WithMessageContaining("go.sum is out of sync"),
978+
),
976979
ReadDiagnostics("b/go.mod", params),
977980
)
978981
for _, d := range params.Diagnostics {

0 commit comments

Comments
 (0)