Skip to content

Commit

Permalink
VerifyNone: cleanup, opts.cleanup = opts.cleanup, nil
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav committed Sep 6, 2022
1 parent a034565 commit cd5fa11
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions leaks.go
Expand Up @@ -84,14 +84,14 @@ type testHelper interface {
// defer VerifyNone(t)
func VerifyNone(t TestingT, options ...Option) {
opts := buildOpts(options...)
cleanup := opts.cleanup
var cleanup func(int)
cleanup, opts.cleanup = opts.cleanup, nil

if h, ok := t.(testHelper); ok {
// Mark this function as a test helper, if available.
h.Helper()
}

// Find does not appreciate cleanups
opts.cleanup = nil
if err := Find(opts); err != nil {
t.Error(err)
}
Expand Down
3 changes: 1 addition & 2 deletions testmain.go
Expand Up @@ -52,13 +52,12 @@ type TestingM interface {
func VerifyTestMain(m TestingM, options ...Option) {
exitCode := m.Run()
opts := buildOpts(options...)

var cleanup func(int)
cleanup, opts.cleanup = opts.cleanup, nil

if cleanup == nil {
cleanup = _osExit
}

defer func() { cleanup(exitCode) }()

if exitCode == 0 {
Expand Down

0 comments on commit cd5fa11

Please sign in to comment.