Update dependencies (#5518)
This commit is contained in:
25
vendor/go.uber.org/goleak/.travis.yml
generated
vendored
25
vendor/go.uber.org/goleak/.travis.yml
generated
vendored
@@ -1,25 +0,0 @@
|
||||
sudo: false
|
||||
language: go
|
||||
go_import_path: go.uber.org/goleak
|
||||
|
||||
env:
|
||||
global:
|
||||
- GO111MODULE=on
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- go: 1.12.x
|
||||
- go: 1.13.x
|
||||
- go: 1.14.x
|
||||
env: LINT=1
|
||||
|
||||
install:
|
||||
- make install
|
||||
|
||||
script:
|
||||
- test -z "$LINT" || make lint
|
||||
- make test
|
||||
|
||||
after_success:
|
||||
- make cover
|
||||
- bash <(curl -s https://codecov.io/bash)
|
||||
35
vendor/go.uber.org/goleak/CHANGELOG.md
generated
vendored
35
vendor/go.uber.org/goleak/CHANGELOG.md
generated
vendored
@@ -4,12 +4,40 @@ All notable changes to this project will be documented in this file.
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [1.1.0]
|
||||
## [1.2.0]
|
||||
### Added
|
||||
- Add Cleanup option that can be used for registering cleanup callbacks. (#78)
|
||||
|
||||
### Changed
|
||||
- Mark VerifyNone as a test helper. (#75)
|
||||
|
||||
Thanks to @tallclair for their contribution to this release.
|
||||
|
||||
[1.2.0]: https://github.com/uber-go/goleak/compare/v1.1.12...v1.2.0
|
||||
|
||||
## [1.1.12]
|
||||
### Fixed
|
||||
- Fixed logic for ignoring trace related goroutines on Go versions 1.16 and above.
|
||||
|
||||
[1.1.12]: https://github.com/uber-go/goleak/compare/v1.1.11...v1.1.12
|
||||
|
||||
## [1.1.11]
|
||||
### Fixed
|
||||
- Documentation fix on how to test.
|
||||
- Update dependency on stretchr/testify to v1.7.0. (#59)
|
||||
- Update dependency on golang.org/x/tools to address CVE-2020-14040. (#62)
|
||||
|
||||
[1.1.11]: https://github.com/uber-go/goleak/compare/v1.1.10...v1.1.11
|
||||
|
||||
## [1.1.10]
|
||||
### Added
|
||||
- [#49]: Add option to ignore current goroutines, which checks for any additional leaks and allows for incremental adoption of goleak in larger projects.
|
||||
|
||||
Thanks to @denis-tingajkin for their contributions to this release.
|
||||
|
||||
[#49]: https://github.com/uber-go/goleak/pull/49
|
||||
[1.1.10]: https://github.com/uber-go/goleak/compare/v1.0.0...v1.1.10
|
||||
|
||||
## [1.0.0]
|
||||
### Changed
|
||||
- Migrate to Go modules.
|
||||
@@ -17,8 +45,7 @@ Thanks to @denis-tingajkin for their contributions to this release.
|
||||
### Fixed
|
||||
- Ignore trace related goroutines that cause false positives with -trace.
|
||||
|
||||
[1.0.0]: https://github.com/uber-go/goleak/compare/v0.10.0...v1.0.0
|
||||
|
||||
## 0.10.0
|
||||
- Initial release.
|
||||
|
||||
[1.0.0]: https://github.com/uber-go/goleak/compare/v0.10.0...v1.0.0
|
||||
[#49]: https://github.com/uber-go/goleak/pull/49
|
||||
|
||||
6
vendor/go.uber.org/goleak/README.md
generated
vendored
6
vendor/go.uber.org/goleak/README.md
generated
vendored
@@ -46,7 +46,7 @@ $ go test -c -o tests
|
||||
|
||||
# Run each test individually, printing "." for successful tests, or the test name
|
||||
# for failing tests.
|
||||
$ for test in $(go test -list . | grep -E "^(Test|Example)"); do ./tests -test.run "^$test\$" &>/dev/null && echo -n "." || echo "\n$test failed"; done
|
||||
$ for test in $(go test -list . | grep -E "^(Test|Example)"); do ./tests -test.run "^$test\$" &>/dev/null && echo -n "." || echo -e "\n$test failed"; done
|
||||
```
|
||||
|
||||
This will only print names of failing tests which can be investigated individually. E.g.,
|
||||
@@ -65,7 +65,7 @@ No breaking changes will be made to exported APIs before 2.0.
|
||||
|
||||
[doc-img]: https://godoc.org/go.uber.org/goleak?status.svg
|
||||
[doc]: https://godoc.org/go.uber.org/goleak
|
||||
[ci-img]: https://travis-ci.com/uber-go/goleak.svg?branch=master
|
||||
[ci]: https://travis-ci.com/uber-go/goleak
|
||||
[ci-img]: https://github.com/uber-go/goleak/actions/workflows/go.yml/badge.svg
|
||||
[ci]: https://github.com/uber-go/goleak/actions/workflows/go.yml
|
||||
[cov-img]: https://codecov.io/gh/uber-go/goleak/branch/master/graph/badge.svg
|
||||
[cov]: https://codecov.io/gh/uber-go/goleak
|
||||
|
||||
26
vendor/go.uber.org/goleak/leaks.go
generated
vendored
26
vendor/go.uber.org/goleak/leaks.go
generated
vendored
@@ -21,6 +21,7 @@
|
||||
package goleak
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"go.uber.org/goleak/internal/stack"
|
||||
@@ -55,6 +56,9 @@ func Find(options ...Option) error {
|
||||
cur := stack.Current().ID()
|
||||
|
||||
opts := buildOpts(options...)
|
||||
if opts.cleanup != nil {
|
||||
return errors.New("Cleanup can only be passed to VerifyNone or VerifyTestMain")
|
||||
}
|
||||
var stacks []stack.Stack
|
||||
retry := true
|
||||
for i := 0; retry; i++ {
|
||||
@@ -69,12 +73,30 @@ func Find(options ...Option) error {
|
||||
return fmt.Errorf("found unexpected goroutines:\n%s", stacks)
|
||||
}
|
||||
|
||||
type testHelper interface {
|
||||
Helper()
|
||||
}
|
||||
|
||||
// VerifyNone marks the given TestingT as failed if any extra goroutines are
|
||||
// found by Find. This is a helper method to make it easier to integrate in
|
||||
// tests by doing:
|
||||
// defer VerifyNone(t)
|
||||
//
|
||||
// defer VerifyNone(t)
|
||||
func VerifyNone(t TestingT, options ...Option) {
|
||||
if err := Find(options...); err != nil {
|
||||
opts := buildOpts(options...)
|
||||
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()
|
||||
}
|
||||
|
||||
if err := Find(opts); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if cleanup != nil {
|
||||
cleanup(0)
|
||||
}
|
||||
}
|
||||
|
||||
42
vendor/go.uber.org/goleak/options.go
generated
vendored
42
vendor/go.uber.org/goleak/options.go
generated
vendored
@@ -41,6 +41,16 @@ type opts struct {
|
||||
filters []func(stack.Stack) bool
|
||||
maxRetries int
|
||||
maxSleep time.Duration
|
||||
cleanup func(int)
|
||||
}
|
||||
|
||||
// implement apply so that opts struct itself can be used as
|
||||
// an Option.
|
||||
func (o *opts) apply(opts *opts) {
|
||||
opts.filters = o.filters
|
||||
opts.maxRetries = o.maxRetries
|
||||
opts.maxSleep = o.maxSleep
|
||||
opts.cleanup = o.cleanup
|
||||
}
|
||||
|
||||
// optionFunc lets us easily write options without a custom type.
|
||||
@@ -57,6 +67,18 @@ func IgnoreTopFunction(f string) Option {
|
||||
})
|
||||
}
|
||||
|
||||
// Cleanup sets up a cleanup function that will be executed at the
|
||||
// end of the leak check.
|
||||
// When passed to [VerifyTestMain], the exit code passed to cleanupFunc
|
||||
// will be set to the exit code of TestMain.
|
||||
// When passed to [VerifyNone], the exit code will be set to 0.
|
||||
// This cannot be passed to [Find].
|
||||
func Cleanup(cleanupFunc func(exitCode int)) Option {
|
||||
return optionFunc(func(opts *opts) {
|
||||
opts.cleanup = cleanupFunc
|
||||
})
|
||||
}
|
||||
|
||||
// IgnoreCurrent records all current goroutines when the option is created, and ignores
|
||||
// them in any future Find/Verify calls.
|
||||
func IgnoreCurrent() Option {
|
||||
@@ -98,8 +120,8 @@ func buildOpts(options ...Option) *opts {
|
||||
return opts
|
||||
}
|
||||
|
||||
func (vo *opts) filter(s stack.Stack) bool {
|
||||
for _, filter := range vo.filters {
|
||||
func (o *opts) filter(s stack.Stack) bool {
|
||||
for _, filter := range o.filters {
|
||||
if filter(s) {
|
||||
return true
|
||||
}
|
||||
@@ -107,14 +129,14 @@ func (vo *opts) filter(s stack.Stack) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (vo *opts) retry(i int) bool {
|
||||
if i >= vo.maxRetries {
|
||||
func (o *opts) retry(i int) bool {
|
||||
if i >= o.maxRetries {
|
||||
return false
|
||||
}
|
||||
|
||||
d := time.Duration(int(time.Microsecond) << uint(i))
|
||||
if d > vo.maxSleep {
|
||||
d = vo.maxSleep
|
||||
if d > o.maxSleep {
|
||||
d = o.maxSleep
|
||||
}
|
||||
time.Sleep(d)
|
||||
return true
|
||||
@@ -154,11 +176,3 @@ func isStdLibStack(s stack.Stack) bool {
|
||||
// Using signal.Notify will start a runtime goroutine.
|
||||
return strings.Contains(s.Full(), "runtime.ensureSigM")
|
||||
}
|
||||
|
||||
func isTraceStack(s stack.Stack) bool {
|
||||
if f := s.FirstFunction(); f != "runtime.goparkunlock" {
|
||||
return false
|
||||
}
|
||||
|
||||
return strings.Contains(s.Full(), "runtime.ReadTrace")
|
||||
}
|
||||
|
||||
18
vendor/go.uber.org/goleak/testmain.go
generated
vendored
18
vendor/go.uber.org/goleak/testmain.go
generated
vendored
@@ -41,9 +41,9 @@ type TestingM interface {
|
||||
// verify that there were no goroutine leaks.
|
||||
// To use it, your TestMain function should look like:
|
||||
//
|
||||
// func TestMain(m *testing.M) {
|
||||
// goleak.VerifyTestMain(m)
|
||||
// }
|
||||
// func TestMain(m *testing.M) {
|
||||
// goleak.VerifyTestMain(m)
|
||||
// }
|
||||
//
|
||||
// See https://golang.org/pkg/testing/#hdr-Main for more details.
|
||||
//
|
||||
@@ -51,13 +51,19 @@ type TestingM interface {
|
||||
// for any goroutine leaks and fail the tests if any leaks were found.
|
||||
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 {
|
||||
if err := Find(options...); err != nil {
|
||||
if err := Find(opts); err != nil {
|
||||
fmt.Fprintf(_osStderr, "goleak: Errors on successful test run: %v\n", err)
|
||||
exitCode = 1
|
||||
}
|
||||
}
|
||||
|
||||
_osExit(exitCode)
|
||||
}
|
||||
|
||||
14
vendor/go.uber.org/goleak/tools.go → vendor/go.uber.org/goleak/tracestack_new.go
generated
vendored
14
vendor/go.uber.org/goleak/tools.go → vendor/go.uber.org/goleak/tracestack_new.go
generated
vendored
@@ -1,4 +1,4 @@
|
||||
// Copyright (c) 2019 Uber Technologies, Inc.
|
||||
// Copyright (c) 2021 Uber Technologies, Inc.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -18,11 +18,17 @@
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
|
||||
// +build tools
|
||||
//go:build go1.16
|
||||
// +build go1.16
|
||||
|
||||
package goleak
|
||||
|
||||
import (
|
||||
// Tools we use during development.
|
||||
_ "golang.org/x/lint/golint"
|
||||
"strings"
|
||||
|
||||
"go.uber.org/goleak/internal/stack"
|
||||
)
|
||||
|
||||
func isTraceStack(s stack.Stack) bool {
|
||||
return strings.Contains(s.Full(), "runtime.ReadTrace")
|
||||
}
|
||||
Reference in New Issue
Block a user