diff --git a/gmeasure/experiment_test.go b/gmeasure/experiment_test.go index d0647272f..9a8745c08 100644 --- a/gmeasure/experiment_test.go +++ b/gmeasure/experiment_test.go @@ -9,7 +9,6 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/onsi/gomega/gleak" "github.com/onsi/gomega/gmeasure" ) @@ -225,7 +224,6 @@ var _ = Describe("Experiment", func() { }) It("can run samples in parallel", func() { - g := gleak.Goroutines() lock := &sync.Mutex{} e.Sample(func(idx int) { @@ -239,8 +237,6 @@ var _ = Describe("Experiment", func() { defer lock.Unlock() Ω(len(indices)).Should(BeNumerically("~", 30, 10)) Ω(indices).Should(ConsistOf(ints(len(indices)))) - - Eventually(gleak.Goroutines).ShouldNot(gleak.HaveLeaked(g)) }) It("panics if the SamplingConfig does not specify a ceiling", func() { diff --git a/gmeasure/gmeasure_suite_test.go b/gmeasure/gmeasure_suite_test.go index d9a664621..2c953fbaf 100644 --- a/gmeasure/gmeasure_suite_test.go +++ b/gmeasure/gmeasure_suite_test.go @@ -5,9 +5,17 @@ import ( . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/onsi/gomega/gleak" ) func TestGmeasure(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "Gmeasure Suite") } + +var _ = BeforeEach(func() { + g := gleak.Goroutines() + DeferCleanup(func() { + Eventually(gleak.Goroutines).ShouldNot(gleak.HaveLeaked(g)) + }) +})