MCPcopy Index your code
hub / github.com/git-bug/git-bug / Run

Method Run

internal/test/test.go:38–72  ·  view source on GitHub ↗
(fn func(t testing.TB))

Source from the content-addressed store, hash-verified

36}
37
38func (f *flaky) Run(fn func(t testing.TB)) {
39 var last error
40
41 for attempt := 1; attempt <= f.o.MaxAttempts; attempt++ {
42 r := &recorder{
43 TB: f.t,
44 fail: func(s string) { last = errors.New(s) },
45 fatal: func(s string) { last = errors.New(s) },
46 }
47
48 func() {
49 failCodes := []int{RecorderFailNow, RecorderFatalf, RecorderFatal}
50 defer func() {
51 if rec := recover(); rec != nil {
52 if code, ok := rec.(int); ok && !slices.Contains(failCodes, code) {
53 panic(rec)
54 }
55 }
56 }()
57
58 fn(r)
59 }()
60
61 if !r.Failed() {
62 return
63 }
64
65 if attempt < f.o.MaxAttempts {
66 backoff := f.o.InitialBackoff * time.Duration(1<<uint(attempt-1))
67 time.Sleep(applyJitter(backoff, f.o.Jitter))
68 }
69 }
70
71 f.t.Fatalf("[%s] test failed after %d attempts: %v", f.t.Name(), f.o.MaxAttempts, last)
72}
73
74func applyJitter(d time.Duration, jitter float64) time.Duration {
75 if jitter == 0 {

Callers 15

TestTitleFilterFunction · 0.80
TestCacheFunction · 0.80
TestSplitURLFunction · 0.80
TestValidateUsernameFunction · 0.80
TestValidateProjectFunction · 0.80
TestGithubImporterFunction · 0.80
TestGithubPushPullFunction · 0.80
rateLimitingErrorFunction · 0.80
expectIssueQuery1Function · 0.80
expectIssueQuery2Function · 0.80
expectIssueQuery3Function · 0.80
expectUserQueryFunction · 0.80

Calls 5

FailedMethod · 0.95
applyJitterFunction · 0.85
FatalfMethod · 0.80
NameMethod · 0.65
NewMethod · 0.45

Tested by 15

TestTitleFilterFunction · 0.64
TestCacheFunction · 0.64
TestSplitURLFunction · 0.64
TestValidateUsernameFunction · 0.64
TestValidateProjectFunction · 0.64
TestGithubImporterFunction · 0.64
TestGithubPushPullFunction · 0.64
rateLimitingErrorFunction · 0.64
expectIssueQuery1Function · 0.64
expectIssueQuery2Function · 0.64
expectIssueQuery3Function · 0.64
expectUserQueryFunction · 0.64