Skip to content

Commit 7124057

Browse files
authored
internal/build: fix crash in MustRunCommandWithOutput (#28709)
1 parent 9258a44 commit 7124057

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

internal/build/util.go

+6-11
Original file line numberDiff line numberDiff line change
@@ -68,23 +68,18 @@ func MustRunCommand(cmd string, args ...string) {
6868
MustRun(exec.Command(cmd, args...))
6969
}
7070

71+
// MustRunCommandWithOutput runs the given command, and ensures that some output will be
72+
// printed while it runs. This is useful for CI builds where the process will be stopped
73+
// when there is no output.
7174
func MustRunCommandWithOutput(cmd string, args ...string) {
72-
var done chan bool
73-
// This is a little loop to generate some output, so CI does not tear down the
74-
// process after 300 seconds.
75+
interval := time.NewTicker(time.Minute)
76+
defer interval.Stop()
7577
go func() {
76-
for i := 0; i < 15; i++ {
78+
for range interval.C {
7779
fmt.Printf("Waiting for command %q\n", cmd)
78-
select {
79-
case <-time.After(time.Minute):
80-
break
81-
case <-done:
82-
return
83-
}
8480
}
8581
}()
8682
MustRun(exec.Command(cmd, args...))
87-
close(done)
8883
}
8984

9085
var warnedAboutGit bool

0 commit comments

Comments
 (0)