Skip to content

Commit

Permalink
minor gleak documentation maintenance (#542)
Browse files Browse the repository at this point in the history
  • Loading branch information
thediveo committed Apr 16, 2022
1 parent 1ce84d5 commit 14c6488
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions docs/index.md
Expand Up @@ -3049,18 +3049,20 @@ the testing frameworks (such as Go's own testing package and Gomega).
### Using Goroutine Snapshots in Leak Testing

Often, it might be sufficient to cover for additional "non-leaky" goroutines by
taking a "snapshot" of goroutines _before_ a test and then _afterwards_ use ths
taking a "snapshot" of goroutines _before_ a test and then _afterwards_ use the
snapshot to filter out the supposedly "non-leaky" goroutines.

```go
var ignoreGood []goroutine.Goroutine
Using Ginkgo's v2 `DeferCleanup` this can be expressed in a compact manner and
without the need for explicitly declaring a variable to carry the list of known
goroutines over from `BeforeEach` to `AfterEach`. This keeps all things declared
neatly in a single place.

```go
BeforeEach(func() {
ignoreGood = Goroutines()
})

AfterEach(func() {
Eventually(Goroutines).ShouldNot(HaveLeaked(ignoreGood))
goods := Goroutines()
DeferCleanup(func() {
Eventually(Goroutines).ShouldNot(HaveLeaked(goods))
})
})
```

Expand Down Expand Up @@ -3183,7 +3185,7 @@ criteria:

### Adjusting Leaky Goroutine Reporting

When `HaveLeaked` finds leaked goroutines, Gomega prints out a description of
When `HaveLeaked` finds leaked goroutines, `gleak` prints out a description of
(only) the _leaked_ goroutines. This is different from panic output that
contains backtraces of all goroutines.

Expand Down

0 comments on commit 14c6488

Please sign in to comment.