mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
audio: Improve test flakiness
This commit is contained in:
parent
25581b2be8
commit
ed7552962d
@ -70,11 +70,21 @@ func TestGC(t *testing.T) {
|
|||||||
runtime.KeepAlive(p)
|
runtime.KeepAlive(p)
|
||||||
p = nil
|
p = nil
|
||||||
runtime.GC()
|
runtime.GC()
|
||||||
|
|
||||||
|
ch := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
defer close(ch)
|
||||||
|
for i := 0; i < 10; i++ {
|
||||||
|
got = PlayersNumForTesting()
|
||||||
|
if want := 0; got == want {
|
||||||
|
return
|
||||||
|
}
|
||||||
// 100[ms] should be enough all the bytes are consumed.
|
// 100[ms] should be enough all the bytes are consumed.
|
||||||
// TODO: This is a darty hack. Would it be possible to use virtual time?
|
// TODO: This is a darty hack. Would it be possible to use virtual time?
|
||||||
time.Sleep(100 * time.Millisecond)
|
time.Sleep(100 * time.Millisecond)
|
||||||
got = PlayersNumForTesting()
|
|
||||||
if want := 0; got != want {
|
|
||||||
t.Errorf("PlayersNum() after GC: got: %d, want: %d", got, want)
|
|
||||||
}
|
}
|
||||||
|
t.Errorf("time out")
|
||||||
|
}()
|
||||||
|
|
||||||
|
<-ch
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user