From b78475ed783db54a2e79d724c2eee81c00c6c875 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 21 Jul 2024 23:31:38 +0900 Subject: [PATCH] audio/internal/convert: try to make the test stable --- audio/internal/convert/float32_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/audio/internal/convert/float32_test.go b/audio/internal/convert/float32_test.go index 268459e19..c2240c922 100644 --- a/audio/internal/convert/float32_test.go +++ b/audio/internal/convert/float32_test.go @@ -18,12 +18,22 @@ import ( "bytes" "io" "math/rand" // TODO: Use math/rand/v2 when the minimum supported version becomes Go 1.22. + "os" "testing" + "time" "unsafe" "github.com/hajimehoshi/ebiten/v2/audio/internal/convert" ) +func TestMain(m *testing.M) { + code := m.Run() + // Tests in this package often fails on GitHub Actions due to unfinished goroutines. + // That's mysterious, but to avoid this, sleep for a while before exiting. + time.Sleep(200 * time.Millisecond) + os.Exit(code) +} + func randInt16s(n int) []int16 { r := make([]int16, n) for i := range r {