From 4b5d86c5f7a9ee4eecf7edf96b87f6bb657e871b Mon Sep 17 00:00:00 2001 From: TheDiveO <6920158+thediveo@users.noreply.github.com> Date: Thu, 5 May 2022 17:32:58 +0200 Subject: [PATCH] fix flaky goroutine leak detection test (#552) --- gleak/have_leaked_matcher.go | 2 ++ gleak/have_leaked_matcher_test.go | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/gleak/have_leaked_matcher.go b/gleak/have_leaked_matcher.go index dd6f7ead6..61bf761a4 100644 --- a/gleak/have_leaked_matcher.go +++ b/gleak/have_leaked_matcher.go @@ -8,6 +8,7 @@ import ( "strconv" "strings" + "github.com/onsi/gomega" "github.com/onsi/gomega/format" "github.com/onsi/gomega/gleak/goroutine" "github.com/onsi/gomega/types" @@ -44,6 +45,7 @@ var standardFilters = []types.GomegaMatcher{ // Ginkgo testing framework IgnoringTopFunction("github.com/onsi/ginkgo/v2/internal.(*Suite).runNode"), IgnoringTopFunction("github.com/onsi/ginkgo/v2/internal.(*Suite).runNode..."), + gomega.And(IgnoringTopFunction("runtime.goexit1"), IgnoringCreator("github.com/onsi/ginkgo/v2/internal.(*Suite).runNode")), IgnoringTopFunction("github.com/onsi/ginkgo/v2/internal/interrupt_handler.(*InterruptHandler).registerForInterrupts..."), IgnoringTopFunction("github.com/onsi/ginkgo/internal/specrunner.(*SpecRunner).registerForInterrupts"), diff --git a/gleak/have_leaked_matcher_test.go b/gleak/have_leaked_matcher_test.go index 7d5d0ce65..3f3acb43b 100644 --- a/gleak/have_leaked_matcher_test.go +++ b/gleak/have_leaked_matcher_test.go @@ -77,7 +77,8 @@ created by main.foo`, }) It("considers testing and runtime goroutines not to be leaks", func() { - Expect(Goroutines()).NotTo(HaveLeaked(), "should not find any leaks by default") + Eventually(Goroutines).WithTimeout(2*time.Second).WithPolling(250*time.Millisecond). + ShouldNot(HaveLeaked(), "should not find any leaks by default") }) When("using signals", func() {