Skip to content

Commit

Permalink
cover the entire gmeasure suite with leak detection
Browse files Browse the repository at this point in the history
  • Loading branch information
onsi committed Sep 19, 2022
1 parent 119d4ce commit 8c54344
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 0 additions & 4 deletions gmeasure/experiment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

"github.com/onsi/gomega/gleak"
"github.com/onsi/gomega/gmeasure"
)

Expand Down Expand Up @@ -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) {
Expand All @@ -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() {
Expand Down
8 changes: 8 additions & 0 deletions gmeasure/gmeasure_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
})

0 comments on commit 8c54344

Please sign in to comment.