audio/internal/convert: try to make the test stable

This commit is contained in:
Hajime Hoshi 2024-07-21 23:31:38 +09:00
parent cdef7df61d
commit b78475ed78

View File

@ -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 {