Matthias Andreas Benkard | 832a54e | 2019-01-29 09:27:38 +0100 | [diff] [blame] | 1 | package types |
| 2 | |
| 3 | import ( |
| 4 | "strconv" |
| 5 | "time" |
| 6 | ) |
| 7 | |
| 8 | const GINKGO_FOCUS_EXIT_CODE = 197 |
| 9 | |
| 10 | /* |
| 11 | SuiteSummary represents the a summary of the test suite and is passed to both |
| 12 | Reporter.SpecSuiteWillBegin |
| 13 | Reporter.SpecSuiteDidEnd |
| 14 | |
| 15 | this is unfortunate as these two methods should receive different objects. When running in parallel |
| 16 | each node does not deterministically know how many specs it will end up running. |
| 17 | |
| 18 | Unfortunately making such a change would break backward compatibility. |
| 19 | |
| 20 | Until Ginkgo 2.0 comes out we will continue to reuse this struct but populate unkown fields |
| 21 | with -1. |
| 22 | */ |
| 23 | type 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 | |
| 41 | type 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 | |
| 56 | func (s SpecSummary) HasFailureState() bool { |
| 57 | return s.State.IsFailure() |
| 58 | } |
| 59 | |
| 60 | func (s SpecSummary) TimedOut() bool { |
| 61 | return s.State == SpecStateTimedOut |
| 62 | } |
| 63 | |
| 64 | func (s SpecSummary) Panicked() bool { |
| 65 | return s.State == SpecStatePanicked |
| 66 | } |
| 67 | |
| 68 | func (s SpecSummary) Failed() bool { |
| 69 | return s.State == SpecStateFailed |
| 70 | } |
| 71 | |
| 72 | func (s SpecSummary) Passed() bool { |
| 73 | return s.State == SpecStatePassed |
| 74 | } |
| 75 | |
| 76 | func (s SpecSummary) Skipped() bool { |
| 77 | return s.State == SpecStateSkipped |
| 78 | } |
| 79 | |
| 80 | func (s SpecSummary) Pending() bool { |
| 81 | return s.State == SpecStatePending |
| 82 | } |
| 83 | |
| 84 | type 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 | |
| 96 | type SpecFailure struct { |
| 97 | Message string |
| 98 | Location CodeLocation |
| 99 | ForwardedPanic string |
| 100 | |
| 101 | ComponentIndex int |
| 102 | ComponentType SpecComponentType |
| 103 | ComponentCodeLocation CodeLocation |
| 104 | } |
| 105 | |
| 106 | type 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 | |
| 125 | func (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 | |
| 135 | type SpecState uint |
| 136 | |
| 137 | const ( |
| 138 | SpecStateInvalid SpecState = iota |
| 139 | |
| 140 | SpecStatePending |
| 141 | SpecStateSkipped |
| 142 | SpecStatePassed |
| 143 | SpecStateFailed |
| 144 | SpecStatePanicked |
| 145 | SpecStateTimedOut |
| 146 | ) |
| 147 | |
| 148 | func (state SpecState) IsFailure() bool { |
| 149 | return state == SpecStateTimedOut || state == SpecStatePanicked || state == SpecStateFailed |
| 150 | } |
| 151 | |
| 152 | type SpecComponentType uint |
| 153 | |
| 154 | const ( |
| 155 | SpecComponentTypeInvalid SpecComponentType = iota |
| 156 | |
| 157 | SpecComponentTypeContainer |
| 158 | SpecComponentTypeBeforeSuite |
| 159 | SpecComponentTypeAfterSuite |
| 160 | SpecComponentTypeBeforeEach |
| 161 | SpecComponentTypeJustBeforeEach |
| 162 | SpecComponentTypeAfterEach |
| 163 | SpecComponentTypeIt |
| 164 | SpecComponentTypeMeasure |
| 165 | ) |
| 166 | |
| 167 | type FlagType uint |
| 168 | |
| 169 | const ( |
| 170 | FlagTypeNone FlagType = iota |
| 171 | FlagTypeFocused |
| 172 | FlagTypePending |
| 173 | ) |