From 09cac123908ac36ee2e554edcd4e238246a6bc78 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 14 Jul 2024 19:31:47 +0900 Subject: [PATCH] audio: bug fix: reduce test flakiness --- audio/audio_test.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/audio/audio_test.go b/audio/audio_test.go index f87e804cc..6aa0c95a3 100644 --- a/audio/audio_test.go +++ b/audio/audio_test.go @@ -16,6 +16,7 @@ package audio_test import ( "bytes" + "os" "runtime" "testing" "time" @@ -34,6 +35,14 @@ func teardown() { context = nil } +func TestMain(m *testing.M) { + code := m.Run() + // 200[ms] should be enough all the players are consumed. + // TODO: This is a dirty hack. Would it be possible to use virtual time? + time.Sleep(200 * time.Millisecond) + os.Exit(code) +} + // Issue #746 func TestGC(t *testing.T) { setup() @@ -138,8 +147,4 @@ func TestNonSeekableSource(t *testing.T) { p.Play() p.Pause() - - // 200[ms] should be enough all the bytes are consumed. - // TODO: This is a dirty hack. Would it be possible to use virtual time? - time.Sleep(200 * time.Millisecond) }