From 51def02a3fd9be7f6efd876df06d2c4439e67b39 Mon Sep 17 00:00:00 2001 From: Cody Gibb Date: Mon, 11 Mar 2019 15:34:04 -0700 Subject: [PATCH] Attempt to fix flakey announce test (#112) --- lib/torrent/scheduler/announcer/announcer_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/torrent/scheduler/announcer/announcer_test.go b/lib/torrent/scheduler/announcer/announcer_test.go index 4f6dd253e..f2e3f39c4 100644 --- a/lib/torrent/scheduler/announcer/announcer_test.go +++ b/lib/torrent/scheduler/announcer/announcer_test.go @@ -15,6 +15,7 @@ package announcer import ( "errors" + "runtime" "testing" "time" @@ -39,6 +40,7 @@ func newMockEvents() *mockEvents { func (e *mockEvents) AnnounceTick() { e.tick <- struct{}{} } func (e *mockEvents) expectTick(t *testing.T) { + runtime.Gosched() select { case <-e.tick: case <-time.After(500 * time.Millisecond): @@ -47,6 +49,7 @@ func (e *mockEvents) expectTick(t *testing.T) { } func (e *mockEvents) expectNoTick(t *testing.T) { + runtime.Gosched() select { case <-e.tick: require.FailNow(t, "Unexpected tick")