Update dependencies (#5518)

This commit is contained in:
hongming
2023-02-12 23:09:20 +08:00
committed by GitHub
parent d3b35fb2da
commit a979342f56
1486 changed files with 126660 additions and 71128 deletions

42
vendor/go.uber.org/goleak/options.go generated vendored
View File

@@ -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")
}