Skip to content

Commit 66c7ca7

Browse files
committed
cmd/go: improve TestScript/reuse_git
Most reuse origin info in git should not list RepoSum; check that. Also add tests of go list -reuse, which were omitted entirely in CL 411398. Also be extra sure there is no repo left in module cache during reuse tests. For #75119. Change-Id: Ia1436b8d9e17db49664d24f1d43c448ac7cd00d2 Reviewed-on: https://go-review.googlesource.com/c/go/+/718380 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Matloob <matloob@google.com> Reviewed-by: Michael Matloob <matloob@golang.org>
1 parent de84ac5 commit 66c7ca7

File tree

1 file changed

+118
-13
lines changed

1 file changed

+118
-13
lines changed

src/cmd/go/testdata/script/reuse_git.txt

Lines changed: 118 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
1414
stdout '"VCS": "git"'
1515
stdout '"URL": ".*/git/hello"'
1616
stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
17+
! stdout '"RepoSum"'
1718
go clean -modcache
1819

1920
# go mod download vcstest/hello should invoke git, print origin info
@@ -28,6 +29,7 @@ stdout '"Query": "latest"'
2829
stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
2930
stdout '"Ref": "HEAD"'
3031
stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
32+
! stdout '"RepoSum"'
3133

3234
# pseudo-version again should not invoke git fetch (it has the version from the @latest query)
3335
# but still be careful not to include a TagSum or a Ref, especially not Ref set to HEAD,
@@ -47,6 +49,7 @@ stdout '"VCS": "git"'
4749
stdout '"URL": ".*/git/hello"'
4850
stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
4951
stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
52+
! stdout '"RepoSum"'
5053

5154
# go mod download vcstest/hello/v9 should fail, still print origin info
5255
! go mod download -x -json vcs-test.golang.org/git/hello.git/v9@latest
@@ -108,6 +111,7 @@ stdout '"URL": ".*/git/tagtests"'
108111
stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
109112
stdout '"Ref": "refs/tags/v0.2.2"'
110113
stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
114+
! stdout '"RepoSum"'
111115

112116
# go mod download vcstest/tagtests@v0.2.2 should print origin info, no TagSum needed
113117
go mod download -x -json vcs-test.golang.org/git/tagtests.git@v0.2.2
@@ -120,6 +124,7 @@ stdout '"URL": ".*/git/tagtests"'
120124
! stdout '"TagSum"'
121125
stdout '"Ref": "refs/tags/v0.2.2"'
122126
stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
127+
! stdout '"RepoSum"'
123128

124129
# go mod download vcstest/tagtests@master needs a TagSum again
125130
go mod download -x -json vcs-test.golang.org/git/tagtests.git@master
@@ -132,6 +137,7 @@ stdout '"URL": ".*/git/tagtests"'
132137
stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
133138
stdout '"Ref": "refs/heads/master"'
134139
stdout '"Hash": "c7818c24fa2f3f714c67d0a6d3e411c85a518d1f"'
140+
! stdout '"RepoSum"'
135141

136142
# go mod download vcstest/prefixtagtests should invoke git, print origin info
137143
go mod download -x -json vcs-test.golang.org/git/prefixtagtests.git/sub@latest
@@ -146,6 +152,7 @@ stdout '"TagPrefix": "sub/"'
146152
stdout '"TagSum": "t1:YGSbWkJ8dn9ORAr[+]BlKHFK/2ZhXLb9hVuYfTZ9D8C7g="'
147153
stdout '"Ref": "refs/tags/sub/v0.0.10"'
148154
stdout '"Hash": "2b7c4692e12c109263cab51b416fcc835ddd7eae"'
155+
! stdout '"RepoSum"'
149156

150157
# go mod download of a bunch of these should fail (some are invalid) but write good JSON for later
151158
! go mod download -json vcs-test.golang.org/git/hello.git@latest vcs-test.golang.org/git/hello.git/v9@latest vcs-test.golang.org/git/hello.git/sub/v9@latest vcs-test.golang.org/git/tagtests.git@latest vcs-test.golang.org/git/tagtests.git@v0.2.2 vcs-test.golang.org/git/tagtests.git@master
@@ -158,6 +165,7 @@ stderr 'git( .*)* fetch'
158165
go clean -modcache
159166

160167
# reuse go mod download vcstest/hello result
168+
go clean -modcache
161169
go mod download -reuse=hello.json -x -json vcs-test.golang.org/git/hello.git@latest
162170
! stderr 'git( .*)* fetch'
163171
stdout '"Reuse": true'
@@ -168,12 +176,10 @@ stdout '"URL": ".*/git/hello"'
168176
stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
169177
stdout '"Ref": "HEAD"'
170178
stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
171-
! stdout '"Dir"'
172-
! stdout '"Info"'
173-
! stdout '"GoMod"'
174-
! stdout '"Zip"'
179+
! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
175180

176181
# reuse go mod download vcstest/hello pseudoversion result
182+
go clean -modcache
177183
go mod download -reuse=hellopseudo.json -x -json vcs-test.golang.org/git/hello.git@v0.0.0-20170922010558-fc3a09f3dc5c
178184
! stderr 'git( .*)* fetch'
179185
stdout '"Reuse": true'
@@ -182,9 +188,10 @@ stdout '"VCS": "git"'
182188
stdout '"URL": ".*/git/hello"'
183189
! stdout '"(Query|TagPrefix|TagSum|Ref)"'
184190
stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
185-
! stdout '"(Dir|Info|GoMod|Zip)"'
191+
! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
186192

187193
# reuse go mod download vcstest/hello@hash
194+
go clean -modcache
188195
go mod download -reuse=hellohash.json -x -json vcs-test.golang.org/git/hello.git@fc3a09f3dc5c
189196
! stderr 'git( .*)* fetch'
190197
stdout '"Reuse": true'
@@ -195,9 +202,10 @@ stdout '"URL": ".*/git/hello"'
195202
! stdout '"(TagPrefix|Ref)"'
196203
stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
197204
stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
198-
! stdout '"(Dir|Info|GoMod|Zip)"'
205+
! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
199206

200207
# reuse go mod download vcstest/hello/v9 error result
208+
go clean -modcache
201209
! go mod download -reuse=hellov9.json -x -json vcs-test.golang.org/git/hello.git/v9@latest
202210
! stderr 'git( .*)* fetch'
203211
stdout '"Reuse": true'
@@ -206,9 +214,10 @@ stdout '"Error":.*no matching versions'
206214
stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
207215
stdout '"Ref": "HEAD"'
208216
stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
209-
! stdout '"(Dir|Info|GoMod|Zip)"'
217+
! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
210218

211219
# reuse go mod download vcstest/hello/sub/v9 error result
220+
go clean -modcache
212221
! go mod download -reuse=hellosubv9.json -x -json vcs-test.golang.org/git/hello.git/sub/v9@latest
213222
! stderr 'git( .*)* fetch'
214223
stdout '"Reuse": true'
@@ -217,9 +226,10 @@ stdout '"TagPrefix": "sub/"'
217226
stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
218227
stdout '"Ref": "HEAD"'
219228
stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
220-
! stdout '"(Dir|Info|GoMod|Zip)"'
229+
! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
221230

222231
# reuse go mod download vcstest/hello@nonexist
232+
go clean -modcache
223233
! go mod download -reuse=hellononexist.json -x -json vcs-test.golang.org/git/hello.git@nonexist
224234
! stderr 'git( .*)* fetch'
225235
stdout '"Reuse": true'
@@ -230,6 +240,7 @@ stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
230240
! stdout '"(Dir|Info|GoMod|Zip)"'
231241

232242
# reuse go mod download vcstest/hello@1234567890123456789012345678901234567890
243+
go clean -modcache
233244
! go mod download -reuse=hellononhash.json -x -json vcs-test.golang.org/git/hello.git@1234567890123456789012345678901234567890
234245
! stderr 'git( .*)* fetch'
235246
stdout '"Reuse": true'
@@ -240,6 +251,7 @@ stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
240251
! stdout '"(Dir|Info|GoMod|Zip)"'
241252

242253
# reuse go mod download vcstest/hello@v0.0.0-20220101120101-123456789abc
254+
go clean -modcache
243255
! go mod download -reuse=hellononpseudo.json -x -json vcs-test.golang.org/git/hello.git@v0.0.0-20220101120101-123456789abc
244256
! stderr 'git( .*)* fetch'
245257
stdout '"Reuse": true'
@@ -250,6 +262,7 @@ stdout '"RepoSum": "r1:c0/9JCZ25lxoBiK3[+]3BhACU4giH49flcJmBynJ[+]Jvmc="'
250262
! stdout '"(Dir|Info|GoMod|Zip)"'
251263

252264
# reuse go mod download vcstest/tagtests result
265+
go clean -modcache
253266
go mod download -reuse=tagtests.json -x -json vcs-test.golang.org/git/tagtests.git@latest
254267
! stderr 'git( .*)* fetch'
255268
stdout '"Reuse": true'
@@ -261,9 +274,10 @@ stdout '"URL": ".*/git/tagtests"'
261274
stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
262275
stdout '"Ref": "refs/tags/v0.2.2"'
263276
stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
264-
! stdout '"(Dir|Info|GoMod|Zip)"'
277+
! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
265278

266279
# reuse go mod download vcstest/tagtests@v0.2.2 result
280+
go clean -modcache
267281
go mod download -reuse=tagtestsv022.json -x -json vcs-test.golang.org/git/tagtests.git@v0.2.2
268282
! stderr 'git( .*)* fetch'
269283
stdout '"Reuse": true'
@@ -275,9 +289,10 @@ stdout '"URL": ".*/git/tagtests"'
275289
! stdout '"TagSum"'
276290
stdout '"Ref": "refs/tags/v0.2.2"'
277291
stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
278-
! stdout '"(Dir|Info|GoMod|Zip)"'
292+
! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
279293

280294
# reuse go mod download vcstest/tagtests@master result
295+
go clean -modcache
281296
go mod download -reuse=tagtestsmaster.json -x -json vcs-test.golang.org/git/tagtests.git@master
282297
! stderr 'git( .*)* fetch'
283298
stdout '"Reuse": true'
@@ -289,9 +304,10 @@ stdout '"URL": ".*/git/tagtests"'
289304
stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
290305
stdout '"Ref": "refs/heads/master"'
291306
stdout '"Hash": "c7818c24fa2f3f714c67d0a6d3e411c85a518d1f"'
292-
! stdout '"(Dir|Info|GoMod|Zip)"'
307+
! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
293308

294309
# reuse go mod download vcstest/tagtests@master result again with all.json
310+
go clean -modcache
295311
go mod download -reuse=all.json -x -json vcs-test.golang.org/git/tagtests.git@master
296312
! stderr 'git( .*)* fetch'
297313
stdout '"Reuse": true'
@@ -303,9 +319,10 @@ stdout '"URL": ".*/git/tagtests"'
303319
stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
304320
stdout '"Ref": "refs/heads/master"'
305321
stdout '"Hash": "c7818c24fa2f3f714c67d0a6d3e411c85a518d1f"'
306-
! stdout '"(Dir|Info|GoMod|Zip)"'
322+
! stdout '"(Dir|Info|GoMod|Zip|RepoSum)"'
307323

308324
# go mod download vcstest/prefixtagtests result with json
325+
go clean -modcache
309326
go mod download -reuse=prefixtagtests.json -x -json vcs-test.golang.org/git/prefixtagtests.git/sub@latest
310327
! stderr 'git( .*)* fetch'
311328
stdout '"Version": "v0.0.10"'
@@ -320,12 +337,14 @@ stdout '"Hash": "2b7c4692e12c109263cab51b416fcc835ddd7eae"'
320337
! stdout '"(Dir|Info|GoMod|Zip)"'
321338

322339
# reuse the bulk results with all.json
340+
go clean -modcache
323341
! go mod download -reuse=all.json -json vcs-test.golang.org/git/hello.git@latest vcs-test.golang.org/git/hello.git/v9@latest vcs-test.golang.org/git/hello.git/sub/v9@latest vcs-test.golang.org/git/tagtests.git@latest vcs-test.golang.org/git/tagtests.git@v0.2.2 vcs-test.golang.org/git/tagtests.git@master
324342
! stderr 'git( .*)* fetch'
325343
stdout '"Reuse": true'
326344
! stdout '"(Dir|Info|GoMod|Zip)"'
327345

328346
# reuse attempt with stale hash should reinvoke git, not report reuse
347+
go clean -modcache
329348
cp tagtestsv022.json tagtestsv022badhash.json
330349
replace '57952' '56952XXX' tagtestsv022badhash.json
331350
go mod download -reuse=tagtestsv022badhash.json -x -json vcs-test.golang.org/git/tagtests.git@v0.2.2
@@ -335,7 +354,7 @@ stdout '"Version": "v0.2.2"'
335354
! stdout '"Query"'
336355
stdout '"VCS": "git"'
337356
stdout '"URL": ".*/git/tagtests"'
338-
! stdout '"(TagPrefix|TagSum)"'
357+
! stdout '"(TagPrefix|TagSum|RepoSum)"'
339358
stdout '"Ref": "refs/tags/v0.2.2"'
340359
stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
341360
stdout '"Dir"'
@@ -344,6 +363,7 @@ stdout '"GoMod"'
344363
stdout '"Zip"'
345364

346365
# reuse with stale repo URL
366+
go clean -modcache
347367
cp tagtestsv022.json tagtestsv022badurl.json
348368
replace 'git/tagtests\"' 'git/tagtestsXXX\"' tagtestsv022badurl.json
349369
go mod download -reuse=tagtestsv022badurl.json -x -json vcs-test.golang.org/git/tagtests.git@v0.2.2
@@ -355,22 +375,107 @@ stdout '"GoMod"'
355375
stdout '"Zip"'
356376

357377
# reuse with stale VCS
378+
go clean -modcache
358379
cp tagtestsv022.json tagtestsv022badvcs.json
359380
replace '\"git\"' '\"gitXXX\"' tagtestsv022badvcs.json
360381
go mod download -reuse=tagtestsv022badvcs.json -x -json vcs-test.golang.org/git/tagtests.git@v0.2.2
361382
! stdout '"Reuse": true'
362383
stdout '"URL": ".*/git/tagtests"'
384+
! stdout '"RepoSum"'
363385

364386
# reuse with stale Dir
387+
go clean -modcache
365388
cp tagtestsv022.json tagtestsv022baddir.json
366389
replace '\t\t\"Ref\":' '\t\t\"Subdir\": \"subdir\",\n\t\t\"Ref\":' tagtestsv022baddir.json
367390
go mod download -reuse=tagtestsv022baddir.json -x -json vcs-test.golang.org/git/tagtests.git@v0.2.2
368391
! stdout '"Reuse": true'
369392
stdout '"URL": ".*/git/tagtests"'
393+
! stdout '"RepoSum"'
370394

371395
# reuse with stale TagSum
396+
go clean -modcache
372397
cp tagtests.json tagtestsbadtagsum.json
373398
replace 'sMEOGo=' 'sMEoGo=XXX' tagtestsbadtagsum.json
374399
go mod download -reuse=tagtestsbadtagsum.json -x -json vcs-test.golang.org/git/tagtests.git@latest
375400
! stdout '"Reuse": true'
376401
stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
402+
! stdout '"RepoSum"'
403+
404+
# go list on repo with no tags
405+
go clean -modcache
406+
go list -x -json -m -retracted -versions vcs-test.golang.org/git/hello.git@latest
407+
stderr 'git( .*)* fetch'
408+
cp stdout hellolist.json
409+
! stdout '"Versions"'
410+
stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
411+
stdout '"VCS": "git"'
412+
stdout '"URL": ".*/git/hello"'
413+
stdout '"Query": "latest"'
414+
! stdout '"TagPrefix"'
415+
stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
416+
stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
417+
! stdout '"RepoSum"'
418+
419+
# reuse go list on repo with no tags
420+
go clean -modcache
421+
go list -x -reuse=hellolist.json -json -m -retracted -versions vcs-test.golang.org/git/hello.git@latest
422+
! stderr 'git( .*)* fetch'
423+
stdout '"Reuse": true'
424+
! stdout '"Versions"'
425+
stdout '"Version": "v0.0.0-20170922010558-fc3a09f3dc5c"'
426+
stdout '"VCS": "git"'
427+
stdout '"URL": ".*/git/hello"'
428+
stdout '"Query": "latest"'
429+
! stdout '"TagPrefix"'
430+
stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
431+
stdout '"Hash": "fc3a09f3dc5cfe0d7a743ea18f1f5226e68b3777"'
432+
! stdout '"RepoSum"'
433+
434+
# reuse with stale list
435+
go clean -modcache
436+
cp hellolist.json hellolistbad.json
437+
replace '47DEQ' 'ZZZ' hellolistbad.json
438+
go clean -modcache
439+
go list -x -reuse=hellolistbad.json -json -m -retracted -versions vcs-test.golang.org/git/hello.git@latest
440+
stderr 'git( .*)* fetch'
441+
! stdout '"Reuse": true'
442+
stdout '"TagSum": "t1:47DEQpj8HBSa[+]/TImW[+]5JCeuQeRkm5NMpJWZG3hSuFU="'
443+
444+
# go list on repo with tags
445+
go clean -modcache
446+
go list -x -json -m -retracted -versions vcs-test.golang.org/git/tagtests.git@latest
447+
cp stdout taglist.json
448+
stderr 'git( .*)* fetch'
449+
stdout '"Versions":'
450+
stdout '"v0.2.1"'
451+
stdout '"v0.2.2"'
452+
stdout '"Version": "v0.2.2"'
453+
stdout '"VCS": "git"'
454+
stdout '"URL": ".*/git/tagtests"'
455+
stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
456+
stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
457+
stdout '"Ref": "refs/tags/v0.2.2"'
458+
459+
# reuse go list on repo with tags
460+
go clean -modcache
461+
go list -reuse=taglist.json -x -json -m -retracted -versions vcs-test.golang.org/git/tagtests.git@latest
462+
! stderr 'git( .*)* fetch'
463+
stdout '"Reuse": true'
464+
stdout '"Versions":'
465+
stdout '"v0.2.1"'
466+
stdout '"v0.2.2"'
467+
stdout '"Version": "v0.2.2"'
468+
stdout '"VCS": "git"'
469+
stdout '"URL": ".*/git/tagtests"'
470+
stdout '"Hash": "59356c8cd18c5fe9a598167d98a6843e52d57952"'
471+
stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'
472+
stdout '"Ref": "refs/tags/v0.2.2"'
473+
474+
# reuse with stale list
475+
go clean -modcache
476+
cp taglist.json taglistbad.json
477+
replace 'Dp7yRKDu' 'ZZZ' taglistbad.json
478+
go list -reuse=taglistbad.json -x -json -m -retracted -versions vcs-test.golang.org/git/tagtests.git@latest
479+
stderr 'git( .*)* fetch'
480+
! stdout '"Reuse": true'
481+
stdout '"TagSum": "t1:Dp7yRKDuE8WjG0429PN9hYWjqhy2te7P9Oki/sMEOGo="'

0 commit comments

Comments
 (0)