-
Notifications
You must be signed in to change notification settings - Fork 12
/
golandreporter.go
67 lines (51 loc) · 1.87 KB
/
golandreporter.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
package golandreporter
import (
"fmt"
"os"
"strings"
"github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/reporters"
"github.com/onsi/ginkgo/reporters/stenographer"
"github.com/onsi/ginkgo/types"
)
type GolandReporter struct{}
func NewGolandReporter() reporters.Reporter {
return GolandReporter{}
}
func NewAutoGolandReporter() reporters.Reporter {
if strings.Contains(os.Getenv("OLDPWD"), "Goland") {
return NewGolandReporter()
} else {
stenographer := stenographer.New(!config.DefaultReporterConfig.NoColor, config.GinkgoConfig.FlakeAttempts > 1, os.Stdout)
return reporters.NewDefaultReporter(config.DefaultReporterConfig, stenographer)
}
}
func (g GolandReporter) SpecSuiteWillBegin(config config.GinkgoConfigType, summary *types.SuiteSummary) {
}
func (g GolandReporter) BeforeSuiteDidRun(setupSummary *types.SetupSummary) {
}
func (g GolandReporter) SpecWillRun(specSummary *types.SpecSummary) {
fmt.Printf("=== RUN %s\n", strings.Join(specSummary.ComponentTexts[1:], " "))
}
func (g GolandReporter) SpecDidComplete(specSummary *types.SpecSummary) {
if specSummary.Passed() {
printResultOutput(specSummary, "PASS")
} else if specSummary.HasFailureState() {
fmt.Printf("%s\n\n", specSummary.Failure.Message)
fmt.Printf("%s\n\n", specSummary.Failure.Location.FullStackTrace)
printResultOutput(specSummary, "FAIL")
} else if specSummary.Skipped() {
printResultOutput(specSummary, "SKIP")
} else if specSummary.Pending() {
printResultOutput(specSummary, "SKIP")
} else {
panic("Unknown test output")
}
}
func (g GolandReporter) AfterSuiteDidRun(setupSummary *types.SetupSummary) {
}
func (g GolandReporter) SpecSuiteDidEnd(summary *types.SuiteSummary) {
}
func printResultOutput(specSummary *types.SpecSummary, result string) {
fmt.Printf("--- %s: %s (%.3fs)\n", result, strings.Join(specSummary.ComponentTexts[1:], " "), specSummary.RunTime.Seconds())
}