Skip to content

Commit

Permalink
tests: Add timeout to forcibly exit after interupt
Browse files Browse the repository at this point in the history
When an interupt it sent forcibly exit after 30s in the case that
cancelling the context doesn't actually cancel the builds.

Signed-off-by: Brian Goff <[email protected]>
  • Loading branch information
cpuguy83 committed Jul 2, 2024
1 parent 71cd047 commit 722cde0
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"os"
"os/signal"
"syscall"
"testing"
"time"

Expand Down Expand Up @@ -72,6 +73,10 @@ func TestMain(m *testing.M) {
// Cancel our signal handler so the normal handler takes over from here.
// This allows subsequent interupts to use the default behavior (exit the program)
done()

<-time.After(30 * time.Second)
fmt.Fprintln(os.Stderr, "Timeout waiting for builds to cancel after interupt")
os.Exit(int(syscall.SIGINT))
}()

defer func() {
Expand Down

0 comments on commit 722cde0

Please sign in to comment.