@@ -40,16 +40,20 @@ import (
40
40
41
41
func TestRelease (t * testing.T ) {
42
42
t .Run ("beta" , func (t * testing.T ) {
43
- testRelease (t , "go1.18beta1" , task .KindBeta )
43
+ testRelease (t , "go1.17" , 18 , "go1. 18beta1" , task .KindBeta )
44
44
})
45
45
t .Run ("rc" , func (t * testing.T ) {
46
- testRelease (t , "go1.18rc1" , task .KindRC )
46
+ testRelease (t , "go1.17" , 18 , "go1. 18rc1" , task .KindRC )
47
47
})
48
48
t .Run ("major" , func (t * testing.T ) {
49
- testRelease (t , "go1.18" , task .KindMajor )
49
+ testRelease (t , "go1.17" , 18 , "go1. 18" , task .KindMajor )
50
50
})
51
51
}
52
52
53
+ func TestDistpack (t * testing.T ) {
54
+ testRelease (t , "go1.20" , 21 , "go1.21" , task .KindMajor )
55
+ }
56
+
53
57
func TestSecurity (t * testing.T ) {
54
58
t .Run ("success" , func (t * testing.T ) {
55
59
testSecurity (t , true )
@@ -96,7 +100,7 @@ type releaseTestDeps struct {
96
100
publishedFiles map [string ]* task.WebsiteFile
97
101
}
98
102
99
- func newReleaseTestDeps (t * testing.T , wantVersion string ) * releaseTestDeps {
103
+ func newReleaseTestDeps (t * testing.T , previousTag , wantVersion string ) * releaseTestDeps {
100
104
if runtime .GOOS != "linux" && runtime .GOOS != "darwin" {
101
105
t .Skip ("Requires bash shell scripting support." )
102
106
}
168
172
169
173
goRepo := task .NewFakeRepo (t , "go" )
170
174
base := goRepo .Commit (goFiles )
171
- goRepo .Tag ("go1.17" , base )
175
+ goRepo .Tag (previousTag , base )
172
176
dlRepo := task .NewFakeRepo (t , "dl" )
173
177
toolsRepo := task .NewFakeRepo (t , "tools" )
174
178
toolsRepo1 := toolsRepo .Commit (map [string ]string {
@@ -238,12 +242,12 @@ esac
238
242
}
239
243
}
240
244
241
- func testRelease (t * testing.T , wantVersion string , kind task.ReleaseKind ) {
242
- deps := newReleaseTestDeps (t , wantVersion )
245
+ func testRelease (t * testing.T , prevTag string , major int , wantVersion string , kind task.ReleaseKind ) {
246
+ deps := newReleaseTestDeps (t , prevTag , wantVersion )
243
247
wd := workflow .New ()
244
248
245
249
deps .gerrit .wantReviewers = []string {"heschi" , "dmitshur" }
246
- v := addSingleReleaseWorkflow (deps .buildTasks , deps .milestoneTasks , deps .versionTasks , wd , 18 , kind , workflow .Const (deps .gerrit .wantReviewers ))
250
+ v := addSingleReleaseWorkflow (deps .buildTasks , deps .milestoneTasks , deps .versionTasks , wd , major , kind , workflow .Const (deps .gerrit .wantReviewers ))
247
251
workflow .Output (wd , "Published Go version" , v )
248
252
249
253
w , err := workflow .Start (wd , map [string ]interface {}{
@@ -253,7 +257,7 @@ func testRelease(t *testing.T, wantVersion string, kind task.ReleaseKind) {
253
257
if err != nil {
254
258
t .Fatal (err )
255
259
}
256
- _ , err = w .Run (deps .ctx , & verboseListener {t : t , onStall : deps .cancel })
260
+ outputs , err : = w .Run (deps .ctx , & verboseListener {t : t , onStall : deps .cancel })
257
261
if err != nil {
258
262
t .Fatal (err )
259
263
}
@@ -262,7 +266,7 @@ func testRelease(t *testing.T, wantVersion string, kind task.ReleaseKind) {
262
266
wantPublishedFiles := map [string ]string {
263
267
wantVersion + ".src.tar.gz" : "source" ,
264
268
}
265
- for _ , t := range releasetargets .TargetsForGo1Point (18 ) {
269
+ for _ , t := range releasetargets .TargetsForGo1Point (major ) {
266
270
switch t .GOOS {
267
271
case "darwin" :
268
272
wantPublishedFiles [wantVersion + "." + t .Name + ".tar.gz" ] = "archive"
@@ -305,12 +309,16 @@ func testRelease(t *testing.T, wantVersion string, kind task.ReleaseKind) {
305
309
if len (wantPublishedFiles ) != 0 {
306
310
t .Errorf ("missing %d published files: %v" , len (wantPublishedFiles ), wantPublishedFiles )
307
311
}
312
+ versionFile := outputs ["VERSION file" ].(string )
313
+ if ! strings .Contains (versionFile , wantVersion ) {
314
+ t .Errorf ("version file should contain %q, got %q" , wantVersion , versionFile )
315
+ }
308
316
checkTGZ (t , dlURL , files , "src.tar.gz" , & task.WebsiteFile {
309
317
OS : "" ,
310
318
Arch : "" ,
311
319
Kind : "source" ,
312
320
}, map [string ]string {
313
- "go/VERSION" : wantVersion ,
321
+ "go/VERSION" : versionFile ,
314
322
"go/src/make.bash" : makeScript ,
315
323
})
316
324
checkContents (t , dlURL , files , "windows-amd64.msi" , & task.WebsiteFile {
@@ -323,24 +331,23 @@ func testRelease(t *testing.T, wantVersion string, kind task.ReleaseKind) {
323
331
Arch : "amd64" ,
324
332
Kind : "archive" ,
325
333
}, map [string ]string {
326
- "go/VERSION" : wantVersion ,
334
+ "go/VERSION" : versionFile ,
327
335
"go/tool/something_orother/compile" : "" ,
328
- "go/pkg/something_orother/race.a" : "" ,
329
336
})
330
337
checkZip (t , dlURL , files , "windows-amd64.zip" , & task.WebsiteFile {
331
338
OS : "windows" ,
332
339
Arch : "amd64" ,
333
340
Kind : "archive" ,
334
341
}, map [string ]string {
335
- "go/VERSION" : wantVersion ,
342
+ "go/VERSION" : versionFile ,
336
343
"go/tool/something_orother/compile" : "" ,
337
344
})
338
345
checkTGZ (t , dlURL , files , "linux-armv6l.tar.gz" , & task.WebsiteFile {
339
346
OS : "linux" ,
340
347
Arch : "armv6l" ,
341
348
Kind : "archive" ,
342
349
}, map [string ]string {
343
- "go/VERSION" : wantVersion ,
350
+ "go/VERSION" : versionFile ,
344
351
"go/tool/something_orother/compile" : "" ,
345
352
})
346
353
checkContents (t , dlURL , files , "darwin-amd64.pkg" , & task.WebsiteFile {
@@ -371,14 +378,14 @@ func testRelease(t *testing.T, wantVersion string, kind task.ReleaseKind) {
371
378
if err != nil {
372
379
t .Fatal (err )
373
380
}
374
- if string (version ) != wantVersion {
375
- t .Errorf ("VERSION file is %q, expected %q" , version , wantVersion )
381
+ if string (version ) != versionFile {
382
+ t .Errorf ("VERSION file is %q, expected %q" , version , versionFile )
376
383
}
377
384
}
378
385
}
379
386
380
387
func testSecurity (t * testing.T , mergeFixes bool ) {
381
- deps := newReleaseTestDeps (t , "go1.18rc1" )
388
+ deps := newReleaseTestDeps (t , "go1.17" , "go1. 18rc1" )
382
389
383
390
// Set up the fake merge process. Once we stop to ask for approval, commit
384
391
// the fix to the public server.
@@ -429,7 +436,7 @@ func testSecurity(t *testing.T, mergeFixes bool) {
429
436
}
430
437
431
438
func TestAdvisoryTrybotFail (t * testing.T ) {
432
- deps := newReleaseTestDeps (t , "go1.18rc1" )
439
+ deps := newReleaseTestDeps (t , "go1.17" , "go1. 18rc1" )
433
440
defaultApprove := deps .buildTasks .ApproveAction
434
441
approvedTrybots := false
435
442
deps .buildTasks .ApproveAction = func (ctx * workflow.TaskContext ) error {
@@ -462,9 +469,17 @@ func TestAdvisoryTrybotFail(t *testing.T) {
462
469
463
470
// makeScript pretends to be make.bash. It creates a fake go command that
464
471
// knows how to fake the commands the release process runs.
465
- const makeScript = `#!/bin/bash
472
+ const makeScript = `#!/bin/bash -eu
466
473
467
474
GO=../
475
+
476
+ if [[ $# >0 && $1 == "-distpack" ]]; then
477
+ mkdir -p $GO/pkg/distpack
478
+ tmp=$(mktemp).tar.gz
479
+ tar czf $tmp -C $GO/.. go
480
+ mv $tmp $GO/pkg/distpack/go1.99.src.tar.gz
481
+ fi
482
+
468
483
mkdir -p $GO/bin
469
484
470
485
cat <<'EOF' >$GO/bin/go
@@ -494,14 +509,30 @@ cp $GO/bin/go $GO/bin/go.exe
494
509
# versimilitude.
495
510
mkdir -p $GO/tool/something_orother/
496
511
touch $GO/tool/something_orother/compile
512
+
513
+ if [[ $# >0 && $1 == "-distpack" ]]; then
514
+ case $GOOS in
515
+ "windows")
516
+ tmp=$(mktemp).zip
517
+ # The zip command isn't installed on our buildlets. Python is.
518
+ (cd $GO/.. && python3 -m zipfile -c $tmp go/)
519
+ mv $tmp $GO/pkg/distpack/go1.99.$GOOS-$GOARCH.zip
520
+ ;;
521
+ *)
522
+ tmp=$(mktemp).tar.gz
523
+ tar czf $tmp -C $GO/.. go
524
+ mv $tmp $GO/pkg/distpack/go1.99.$GOOS-$GOARCH.tar.gz
525
+ ;;
526
+ esac
527
+ fi
497
528
`
498
529
499
530
// allScript pretends to be all.bash. It is hardcoded to pass.
500
531
const allScript = `#!/bin/bash -eu
501
532
502
533
echo "I'm a test! :D"
503
534
504
- if [[ $GO_BUILDER_NAME =~ "js-wasm" ]]; then
535
+ if [[ $GO_BUILDER_NAME = "js-wasm" ]]; then
505
536
echo "Oh no, WASM is broken"
506
537
exit 1
507
538
fi
0 commit comments