blob: baf1bd1c474cc55a9e1445bc4b196643c7cb5b8d [file] [log] [blame]
Matthias Andreas Benkard832a54e2019-01-29 09:27:38 +01001package types
2
3import (
4 "strconv"
5 "time"
6)
7
8const GINKGO_FOCUS_EXIT_CODE = 197
9
10/*
11SuiteSummary represents the a summary of the test suite and is passed to both
12Reporter.SpecSuiteWillBegin
13Reporter.SpecSuiteDidEnd
14
15this is unfortunate as these two methods should receive different objects. When running in parallel
16each node does not deterministically know how many specs it will end up running.
17
18Unfortunately making such a change would break backward compatibility.
19
20Until Ginkgo 2.0 comes out we will continue to reuse this struct but populate unkown fields
21with -1.
22*/
23type SuiteSummary struct {
24 SuiteDescription string
25 SuiteSucceeded bool
26 SuiteID string
27
28 NumberOfSpecsBeforeParallelization int
29 NumberOfTotalSpecs int
30 NumberOfSpecsThatWillBeRun int
31 NumberOfPendingSpecs int
32 NumberOfSkippedSpecs int
33 NumberOfPassedSpecs int
34 NumberOfFailedSpecs int
35 // Flaked specs are those that failed initially, but then passed on a
36 // subsequent try.
37 NumberOfFlakedSpecs int
38 RunTime time.Duration
39}
40
41type SpecSummary struct {
42 ComponentTexts []string
43 ComponentCodeLocations []CodeLocation
44
45 State SpecState
46 RunTime time.Duration
47 Failure SpecFailure
48 IsMeasurement bool
49 NumberOfSamples int
50 Measurements map[string]*SpecMeasurement
51
52 CapturedOutput string
53 SuiteID string
54}
55
56func (s SpecSummary) HasFailureState() bool {
57 return s.State.IsFailure()
58}
59
60func (s SpecSummary) TimedOut() bool {
61 return s.State == SpecStateTimedOut
62}
63
64func (s SpecSummary) Panicked() bool {
65 return s.State == SpecStatePanicked
66}
67
68func (s SpecSummary) Failed() bool {
69 return s.State == SpecStateFailed
70}
71
72func (s SpecSummary) Passed() bool {
73 return s.State == SpecStatePassed
74}
75
76func (s SpecSummary) Skipped() bool {
77 return s.State == SpecStateSkipped
78}
79
80func (s SpecSummary) Pending() bool {
81 return s.State == SpecStatePending
82}
83
84type SetupSummary struct {
85 ComponentType SpecComponentType
86 CodeLocation CodeLocation
87
88 State SpecState
89 RunTime time.Duration
90 Failure SpecFailure
91
92 CapturedOutput string
93 SuiteID string
94}
95
96type SpecFailure struct {
97 Message string
98 Location CodeLocation
99 ForwardedPanic string
100
101 ComponentIndex int
102 ComponentType SpecComponentType
103 ComponentCodeLocation CodeLocation
104}
105
106type SpecMeasurement struct {
107 Name string
108 Info interface{}
109 Order int
110
111 Results []float64
112
113 Smallest float64
114 Largest float64
115 Average float64
116 StdDeviation float64
117
118 SmallestLabel string
119 LargestLabel string
120 AverageLabel string
121 Units string
122 Precision int
123}
124
125func (s SpecMeasurement) PrecisionFmt() string {
126 if s.Precision == 0 {
127 return "%f"
128 }
129
130 str := strconv.Itoa(s.Precision)
131
132 return "%." + str + "f"
133}
134
135type SpecState uint
136
137const (
138 SpecStateInvalid SpecState = iota
139
140 SpecStatePending
141 SpecStateSkipped
142 SpecStatePassed
143 SpecStateFailed
144 SpecStatePanicked
145 SpecStateTimedOut
146)
147
148func (state SpecState) IsFailure() bool {
149 return state == SpecStateTimedOut || state == SpecStatePanicked || state == SpecStateFailed
150}
151
152type SpecComponentType uint
153
154const (
155 SpecComponentTypeInvalid SpecComponentType = iota
156
157 SpecComponentTypeContainer
158 SpecComponentTypeBeforeSuite
159 SpecComponentTypeAfterSuite
160 SpecComponentTypeBeforeEach
161 SpecComponentTypeJustBeforeEach
162 SpecComponentTypeAfterEach
163 SpecComponentTypeIt
164 SpecComponentTypeMeasure
165)
166
167type FlagType uint
168
169const (
170 FlagTypeNone FlagType = iota
171 FlagTypeFocused
172 FlagTypePending
173)