Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
kardolus
GitHub Repository: kardolus/chatgpt-cli
Path: blob/main/vendor/github.com/sclevine/spec/report/log.go
2880 views
1
package report
2
3
import (
4
"io/ioutil"
5
"testing"
6
7
"github.com/sclevine/spec"
8
)
9
10
// Log reports specs via the testing log methods and only affects verbose runs.
11
type Log struct{}
12
13
func (Log) Start(t *testing.T, plan spec.Plan) {
14
t.Helper()
15
t.Log("Suite:", plan.Text)
16
t.Logf("Total: %d | Focused: %d | Pending: %d", plan.Total, plan.Focused, plan.Pending)
17
if plan.HasRandom {
18
t.Log("Random seed:", plan.Seed)
19
}
20
if plan.HasFocus {
21
t.Log("Focus is active.")
22
}
23
}
24
25
func (Log) Specs(t *testing.T, specs <-chan spec.Spec) {
26
t.Helper()
27
var passed, failed, skipped int
28
for s := range specs {
29
switch {
30
case s.Failed:
31
failed++
32
if testing.Verbose() {
33
if out, err := ioutil.ReadAll(s.Out); err == nil {
34
t.Logf("%s", out)
35
}
36
}
37
case s.Skipped:
38
skipped++
39
default:
40
passed++
41
}
42
}
43
t.Logf("Passed: %d | Failed: %d | Skipped: %d", passed, failed, skipped)
44
}
45
46