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