Skip to content

Commit bb0a9cd

Browse files
committed
gopls: remove go.sum files from integration tests
Explicit go.sum files in the txtar data for tests makes it harder to modify the tests. This CL replaces the ones in the gopls integration tests with calls to WriteGoSum in test setup. And as part of modernization, a few 'interface{}'s have been replaced with 'any's. Change-Id: I951fa6d7b2ed780df68f4bc0d043f0738612da28 Reviewed-on: https://go-review.googlesource.com/c/tools/+/644335 Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent edafbe5 commit bb0a9cd

File tree

16 files changed

+28
-83
lines changed

16 files changed

+28
-83
lines changed

gopls/internal/test/integration/codelens/codelens_test.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,6 @@ module mod.com/a
261261
go 1.22
262262
263263
require golang.org/x/hello v1.2.3
264-
-- go.sum --
265-
golang.org/x/hello v1.2.3 h1:7Wesfkx/uBd+eFgPrq0irYj/1XfmbvLV8jZ/W7C2Dwg=
266-
golang.org/x/hello v1.2.3/go.mod h1:OgtlzsxVMUUdsdQCIDYgaauCTH47B8T8vofouNJfzgY=
267264
-- main.go --
268265
package main
269266
@@ -282,6 +279,7 @@ require golang.org/x/hello v1.3.3
282279
`
283280

284281
WithOptions(
282+
WriteGoSum("."),
285283
ProxyFiles(proxyWithLatest),
286284
).Run(t, shouldUpdateDep, func(t *testing.T, env *Env) {
287285
env.RunGoCommand("mod", "vendor")
@@ -335,11 +333,6 @@ require golang.org/x/hello v1.0.0
335333
require golang.org/x/unused v1.0.0
336334
337335
// EOF
338-
-- go.sum --
339-
golang.org/x/hello v1.0.0 h1:qbzE1/qT0/zojAMd/JcPsO2Vb9K4Bkeyq0vB2JGMmsw=
340-
golang.org/x/hello v1.0.0/go.mod h1:WW7ER2MRNXWA6c8/4bDIek4Hc/+DofTrMaQQitGXcco=
341-
golang.org/x/unused v1.0.0 h1:LecSbCn5P3vTcxubungSt1Pn4D/WocCaiWOPDC0y0rw=
342-
golang.org/x/unused v1.0.0/go.mod h1:ihoW8SgWzugwwj0N2SfLfPZCxTB1QOVfhMfB5PWTQ8U=
343336
-- main.go --
344337
package main
345338
@@ -349,7 +342,10 @@ func main() {
349342
_ = hi.Goodbye
350343
}
351344
`
352-
WithOptions(ProxyFiles(proxy)).Run(t, shouldRemoveDep, func(t *testing.T, env *Env) {
345+
WithOptions(
346+
WriteGoSum("."),
347+
ProxyFiles(proxy),
348+
).Run(t, shouldRemoveDep, func(t *testing.T, env *Env) {
353349
env.OpenFile("go.mod")
354350
env.RegexpReplace("go.mod", "// EOF", "// EOF unsaved edit") // unsaved edits ok
355351
env.ExecuteCodeLensCommand("go.mod", command.Tidy, nil)

gopls/internal/test/integration/completion/completion_test.go

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,9 +276,6 @@ module mod.com
276276
go 1.14
277277
278278
require example.com v1.2.3
279-
-- go.sum --
280-
example.com v1.2.3 h1:ihBTGWGjTU3V4ZJ9OmHITkU9WQ4lGdQkMjgyLFk0FaY=
281-
example.com v1.2.3/go.mod h1:Y2Rc5rVWjWur0h3pd9aEvK5Pof8YKDANh9gHA2Maujo=
282279
-- main.go --
283280
package main
284281
@@ -295,6 +292,7 @@ func _() {
295292
}
296293
`
297294
WithOptions(
295+
WriteGoSum("."),
298296
ProxyFiles(proxy),
299297
).Run(t, mod, func(t *testing.T, env *Env) {
300298
// Make sure the dependency is in the module cache and accessible for
@@ -347,9 +345,6 @@ module mod.com
347345
go 1.14
348346
349347
require example.com v1.2.3
350-
-- go.sum --
351-
example.com v1.2.3 h1:ihBTGWGjTU3V4ZJ9OmHITkU9WQ4lGdQkMjgyLFk0FaY=
352-
example.com v1.2.3/go.mod h1:Y2Rc5rVWjWur0h3pd9aEvK5Pof8YKDANh9gHA2Maujo=
353348
-- useblah.go --
354349
// +build hidden
355350
@@ -361,7 +356,9 @@ package mainmod
361356
362357
const Name = "mainmod"
363358
`
364-
WithOptions(ProxyFiles(proxy)).Run(t, files, func(t *testing.T, env *Env) {
359+
WithOptions(
360+
WriteGoSum("."),
361+
ProxyFiles(proxy)).Run(t, files, func(t *testing.T, env *Env) {
365362
env.CreateBuffer("import.go", "package pkg\nvar _ = mainmod.Name\n")
366363
env.SaveBuffer("import.go")
367364
content := env.ReadWorkspaceFile("import.go")

gopls/internal/test/integration/diagnostics/diagnostics_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,6 @@ module mod.com
421421
go 1.12
422422
423423
require foo.test v1.2.3
424-
-- go.sum --
425-
foo.test v1.2.3 h1:TMA+lyd1ck0TqjSFpNe4T6cf/K6TYkoHwOOcMBMjaEw=
426-
foo.test v1.2.3/go.mod h1:Ij3kyLIe5lzjycjh13NL8I2gX0quZuTdW0MnmlwGBL4=
427424
-- print.go --
428425
package lib
429426
@@ -451,6 +448,7 @@ const Answer = 42
451448

452449
func TestResolveDiagnosticWithDownload(t *testing.T) {
453450
WithOptions(
451+
WriteGoSum("."),
454452
ProxyFiles(testPackageWithRequireProxy),
455453
).Run(t, testPackageWithRequire, func(t *testing.T, env *Env) {
456454
env.OpenFile("print.go")
@@ -1753,9 +1751,6 @@ module mod.com
17531751
go 1.12
17541752
17551753
require nested.com v1.0.0
1756-
-- go.sum --
1757-
nested.com v1.0.0 h1:I6spLE4CgFqMdBPc+wTV2asDO2QJ3tU0YAT+jkLeN1I=
1758-
nested.com v1.0.0/go.mod h1:ly53UzXQgVjSlV7wicdBB4p8BxfytuGT1Xcyv0ReJfI=
17591754
-- main.go --
17601755
package main
17611756
@@ -1779,6 +1774,7 @@ package hello
17791774
func helloHelper() {}
17801775
`
17811776
WithOptions(
1777+
WriteGoSum("."),
17821778
ProxyFiles(proxy),
17831779
Modes(Default),
17841780
).Run(t, nested, func(t *testing.T, env *Env) {

gopls/internal/test/integration/misc/configuration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ var ErrFoo = errors.New("foo")
186186
cfg.Env = map[string]string{
187187
"AN_ARBITRARY_VAR": "FOO",
188188
}
189-
cfg.Settings = map[string]interface{}{
189+
cfg.Settings = map[string]any{
190190
"staticcheck": true,
191191
}
192192
env.ChangeConfiguration(cfg)

gopls/internal/test/integration/misc/definition_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,17 +466,14 @@ module example.com/a
466466
go 1.14
467467
require other.com/b v1.0.0
468468
469-
-- go.sum --
470-
other.com/b v1.0.0 h1:1wb3PMGdet5ojzrKl+0iNksRLnOM9Jw+7amBNqmYwqk=
471-
other.com/b v1.0.0/go.mod h1:TgHQFucl04oGT+vrUm/liAzukYHNxCwKNkQZEyn3m9g=
472-
473469
-- a.go --
474470
package a
475471
import "other.com/b"
476472
const _ = b.K
477473
478474
`
479475
WithOptions(
476+
WriteGoSum("."),
480477
ProxyFiles(proxy),
481478
Modes(Default), // fails in 'experimental' mode
482479
).Run(t, src, func(t *testing.T, env *Env) {

gopls/internal/test/integration/misc/highlight_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ module mod.com
9595
go 1.12
9696
9797
require example.com v1.2.3
98-
-- go.sum --
99-
example.com v1.2.3 h1:WFzrgiQJwEDJNLDUOV1f9qlasQkvzXf2UNLaNIqbWsI=
100-
example.com v1.2.3/go.mod h1:Y2Rc5rVWjWur0h3pd9aEvK5Pof8YKDANh9gHA2Maujo=
10198
-- main.go --
10299
package main
103100
@@ -110,6 +107,7 @@ func main() {}`
110107

111108
WithOptions(
112109
ProxyFiles(proxy),
110+
WriteGoSum("."),
113111
).Run(t, mod, func(t *testing.T, env *Env) {
114112
env.OpenFile("main.go")
115113

gopls/internal/test/integration/misc/references_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,10 +376,6 @@ module example.com/a
376376
go 1.14
377377
require other.com/b v1.0.0
378378
379-
-- go.sum --
380-
other.com/b v1.0.0 h1:9WyCKS+BLAMRQM0CegP6zqP2beP+ShTbPaARpNY31II=
381-
other.com/b v1.0.0/go.mod h1:TgHQFucl04oGT+vrUm/liAzukYHNxCwKNkQZEyn3m9g=
382-
383379
-- a.go --
384380
package a
385381
import "other.com/b"
@@ -388,6 +384,7 @@ var _ b.B
388384
389385
`
390386
WithOptions(
387+
WriteGoSum("."),
391388
ProxyFiles(proxy),
392389
Modes(Default), // fails in 'experimental' mode
393390
).Run(t, src, func(t *testing.T, env *Env) {

gopls/internal/test/integration/misc/vendor_test.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ module mod.com
3131
go 1.14
3232
3333
require golang.org/x/hello v1.2.3
34-
-- go.sum --
35-
golang.org/x/hello v1.2.3 h1:EcMp5gSkIhaTkPXp8/3+VH+IFqTpk3ZbpOhqk0Ncmho=
36-
golang.org/x/hello v1.2.3/go.mod h1:WW7ER2MRNXWA6c8/4bDIek4Hc/+DofTrMaQQitGXcco=
3734
-- vendor/modules.txt --
3835
-- a/a1.go --
3936
package a
@@ -48,6 +45,7 @@ func _() {
4845
WithOptions(
4946
Modes(Default),
5047
ProxyFiles(basicProxy),
48+
WriteGoSum("."),
5149
).Run(t, pkgThatUsesVendoring, func(t *testing.T, env *Env) {
5250
env.OpenFile("a/a1.go")
5351
d := &protocol.PublishDiagnosticsParams{}
@@ -71,9 +69,6 @@ module mod.com
7169
go 1.14
7270
7371
require golang.org/x/hello v1.2.3
74-
-- go.sum --
75-
golang.org/x/hello v1.2.3 h1:EcMp5gSkIhaTkPXp8/3+VH+IFqTpk3ZbpOhqk0Ncmho=
76-
golang.org/x/hello v1.2.3/go.mod h1:WW7ER2MRNXWA6c8/4bDIek4Hc/+DofTrMaQQitGXcco=
7772
-- main.go --
7873
package main
7974
@@ -86,6 +81,7 @@ func main() {
8681
WithOptions(
8782
Modes(Default),
8883
ProxyFiles(basicProxy),
84+
WriteGoSum("."),
8985
).Run(t, src, func(t *testing.T, env *Env) {
9086
env.OpenFile("main.go")
9187
env.AfterChange(NoDiagnostics())

gopls/internal/test/integration/misc/vuln_test.go

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -368,13 +368,6 @@ require (
368368
golang.org/amod v1.0.0 // indirect
369369
golang.org/bmod v0.5.0 // indirect
370370
)
371-
-- go.sum --
372-
golang.org/amod v1.0.0 h1:EUQOI2m5NhQZijXZf8WimSnnWubaFNrrKUH/PopTN8k=
373-
golang.org/amod v1.0.0/go.mod h1:yvny5/2OtYFomKt8ax+WJGvN6pfN1pqjGnn7DQLUi6E=
374-
golang.org/bmod v0.5.0 h1:KgvUulMyMiYRB7suKA0x+DfWRVdeyPgVJvcishTH+ng=
375-
golang.org/bmod v0.5.0/go.mod h1:f6o+OhF66nz/0BBc/sbCsshyPRKMSxZIlG50B/bsM4c=
376-
golang.org/cmod v1.1.3 h1:PJ7rZFTk7xGAunBRDa0wDe7rZjZ9R/vr1S2QkVVCngQ=
377-
golang.org/cmod v1.1.3/go.mod h1:eCR8dnmvLYQomdeAZRCPgS5JJihXtqOQrpEkNj5feQA=
378371
-- x/x.go --
379372
package x
380373
@@ -497,7 +490,7 @@ func vulnTestEnv(proxyData string) (*vulntest.DB, []RunOption, error) {
497490
"_GOPLS_TEST_BINARY_RUN_AS_GOPLS": "true", // needed to run `gopls vulncheck`.
498491
"GOSUMDB": "off",
499492
}
500-
return db, []RunOption{ProxyFiles(proxyData), ev, settings}, nil
493+
return db, []RunOption{ProxyFiles(proxyData), ev, settings, WriteGoSum(".")}, nil
501494
}
502495

503496
func TestRunVulncheckPackageDiagnostics(t *testing.T) {
@@ -675,7 +668,7 @@ func TestRunGovulncheck_Expiry(t *testing.T) {
675668
})
676669
}
677670

678-
func stringify(a interface{}) string {
671+
func stringify(a any) string {
679672
data, _ := json.Marshal(a)
680673
return string(data)
681674
}
@@ -814,9 +807,6 @@ go 1.18
814807
815808
require golang.org/bmod v0.5.0
816809
817-
-- go.sum --
818-
golang.org/bmod v0.5.0 h1:MT/ysNRGbCiURc5qThRFWaZ5+rK3pQRPo9w7dYZfMDk=
819-
golang.org/bmod v0.5.0/go.mod h1:k+zl+Ucu4yLIjndMIuWzD/MnOHy06wqr3rD++y0abVs=
820810
-- x/x.go --
821811
package x
822812

gopls/internal/test/integration/modfile/modfile_test.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,6 @@ go 1.12
808808
require (
809809
example.com v1.2.3
810810
)
811-
-- go.sum --
812811
-- main.go --
813812
package main
814813
@@ -918,11 +917,6 @@ module mod.com
918917
go 1.12
919918
920919
require hasdep.com v1.2.3
921-
-- go.sum --
922-
example.com v1.2.3 h1:ihBTGWGjTU3V4ZJ9OmHITkU9WQ4lGdQkMjgyLFk0FaY=
923-
example.com v1.2.3/go.mod h1:Y2Rc5rVWjWur0h3pd9aEvK5Pof8YKDANh9gHA2Maujo=
924-
hasdep.com v1.2.3 h1:00y+N5oD+SpKoqV1zP2VOPawcW65Zb9NebANY3GSzGI=
925-
hasdep.com v1.2.3/go.mod h1:ePVZOlez+KZEOejfLPGL2n4i8qiAjrkhQZ4wcImqAes=
926920
-- main.go --
927921
package main
928922
@@ -957,19 +951,13 @@ go 1.12
957951
958952
require hasdep.com v1.2.3
959953
require random.com v1.2.3
960-
-- go.sum --
961-
example.com v1.2.3 h1:ihBTGWGjTU3V4ZJ9OmHITkU9WQ4lGdQkMjgyLFk0FaY=
962-
example.com v1.2.3/go.mod h1:Y2Rc5rVWjWur0h3pd9aEvK5Pof8YKDANh9gHA2Maujo=
963-
hasdep.com v1.2.3 h1:00y+N5oD+SpKoqV1zP2VOPawcW65Zb9NebANY3GSzGI=
964-
hasdep.com v1.2.3/go.mod h1:ePVZOlez+KZEOejfLPGL2n4i8qiAjrkhQZ4wcImqAes=
965-
random.com v1.2.3 h1:PzYTykzqqH6+qU0dIgh9iPFbfb4Mm8zNBjWWreRKtx0=
966-
random.com v1.2.3/go.mod h1:8EGj+8a4Hw1clAp8vbaeHAsKE4sbm536FP7nKyXO+qQ=
967954
-- main.go --
968955
package main
969956
970957
func main() {}
971958
`
972959
WithOptions(
960+
WriteGoSum("."),
973961
ProxyFiles(proxy),
974962
).Run(t, mod, func(t *testing.T, env *Env) {
975963
d := &protocol.PublishDiagnosticsParams{}
@@ -1010,7 +998,6 @@ go 1.12
1010998
require (
1011999
example.com v1.2.3
10121000
)
1013-
-- go.sum --
10141001
-- main.go --
10151002
package main
10161003
@@ -1078,7 +1065,6 @@ func Goodbye() {
10781065
module mod.com
10791066
10801067
go 1.12
1081-
-- go.sum --
10821068
-- main.go --
10831069
package main
10841070

0 commit comments

Comments
 (0)