42
}
43
44
>
func (r timeoutReport) reportAttemptErrors(tb testing.TB) {
report.go
45
>
reportAttemptErrors(tb, r.failures)
46
>
}
47
48
>
func (r timeoutReport) reportTimeout(tb testing.TB, funcName, timeoutMsg string) {
report.go
49
>
r.reportAttemptErrors(tb)
50
>
message := fmt.Sprintf("condition not satisfied after %v", r.effectiveTimeout)
51
>
if timeoutMsg != "" {
52
message = fmt.Sprintf("%s (not satisfied after %v)", timeoutMsg, r.effectiveTimeout)
53
}
54
>
tb.Fatalf("%s: %s\ndetails:\n attempts = %d\n attempt timeouts = %d",
report.go
55
>
funcName, message, r.attempts, r.attemptTimeouts)
56
}
57
58
>
func reportAttemptErrors(tb testing.TB, failures []attemptFailure) {
report.go
59
>
if len(failures) == 0 {
60
return
61
}
62
64
>
b.WriteString("attempt errors:")
65
>
if len(failures) <= reportHeadAttempts+reportTailAttempts {
66
for _, f := range failures {
67
writeAttemptFailure(&b, f)
68
}
70
>
for _, f := range failures[:reportHeadAttempts] {
71
>
writeAttemptFailure(&b, f)
72
>
}
73
>
omitted := len(failures) - reportHeadAttempts - reportTailAttempts
74
>
fmt.Fprintf(&b, "\n ... %d attempts omitted ...", omitted)
75
>
for _, f := range failures[len(failures)-reportTailAttempts:] {
76
>
writeAttemptFailure(&b, f)
77
>
}
78
}
80
}
81
82
>
func writeAttemptFailure(b *strings.Builder, f attemptFailure) {
report.go
83
>
fmt.Fprintf(b, "\n\n --- attempt %d ---", f.attempt)
84
>
if len(f.errors) == 0 {
85
b.WriteString("\n (attempt failed without recorded assertion output)")
86
return
87
}
89
>
for line := range strings.SplitSeq(e, "\n") {
90
>
b.WriteString("\n ")
91
>
b.WriteString(line)
92
>
}
93
}
94
}