-
-
Notifications
You must be signed in to change notification settings - Fork 288
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix false positive gleaks when using ginkgo -p (#577)
- Loading branch information
Showing
4 changed files
with
73 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package gleak | ||
|
||
import "os" | ||
|
||
// IgnoreGinkgoParallelClient must be called in a BeforeSuite whenever a test | ||
// suite is run in parallel with other test suites using "ginkgo -p". Calling | ||
// IgnoreGinkgoParallelClient checks for a Ginkgo-related background go routine | ||
// and then updates gleak's internal ignore list to specifically ignore this | ||
// background go routine by its ("random") ID. | ||
func IgnoreGinkgoParallelClient() { | ||
ignoreCreator := "net/rpc.NewClientWithCodec" | ||
if os.Getenv("GINKGO_PARALLEL_PROTOCOL") == "HTTP" { | ||
ignoreCreator = "net/http.(*Transport).dialConn" | ||
} | ||
ignores := []Goroutine{} | ||
for _, g := range Goroutines() { | ||
if g.CreatorFunction == ignoreCreator { | ||
ignores = append(ignores, g) | ||
} | ||
} | ||
if len(ignores) == 0 { | ||
return | ||
} | ||
standardFilters = append(standardFilters, IgnoringGoroutines(ignores)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters