(options: EventParserOptions)
| 125 | } |
| 126 | |
| 127 | export function createXcodebuildEventParser(options: EventParserOptions): XcodebuildEventParser { |
| 128 | const { operation, onEvent, onUnrecognizedLine } = options; |
| 129 | const kind: BuildLikeKind = |
| 130 | options.kind ?? (operation === 'TEST' ? 'test-result' : 'build-result'); |
| 131 | |
| 132 | let stdoutBuffer = ''; |
| 133 | let stderrBuffer = ''; |
| 134 | let completedCount = 0; |
| 135 | let failedCount = 0; |
| 136 | let skippedCount = 0; |
| 137 | let testCasesCompletedSinceSwiftTestingSummary = 0; |
| 138 | let testCasesFailedSinceSwiftTestingSummary = 0; |
| 139 | let detectedXcresultPath: string | null = null; |
| 140 | |
| 141 | let pendingError: { |
| 142 | message: string; |
| 143 | location?: string; |
| 144 | rawLines: string[]; |
| 145 | } | null = null; |
| 146 | |
| 147 | const pendingFailureDiagnostics = new Map< |
| 148 | string, |
| 149 | Array<{ suiteName?: string; testName?: string; message: string; location?: string }> |
| 150 | >(); |
| 151 | const pendingFailureDurations = new Map<string, number>(); |
| 152 | |
| 153 | function getFailureKey(suiteName?: string, testName?: string): string | null { |
| 154 | if (!suiteName && !testName) { |
| 155 | return null; |
| 156 | } |
| 157 | |
| 158 | return `${suiteName ?? ''}::${testName ?? ''}`.trim().toLowerCase(); |
| 159 | } |
| 160 | |
| 161 | function emitFailureFragment(failure: { |
| 162 | suiteName?: string; |
| 163 | testName?: string; |
| 164 | message: string; |
| 165 | location?: string; |
| 166 | durationMs?: number; |
| 167 | }): void { |
| 168 | if (operation !== 'TEST') { |
| 169 | return; |
| 170 | } |
| 171 | |
| 172 | onEvent({ |
| 173 | kind: 'test-result', |
| 174 | fragment: 'test-failure', |
| 175 | operation: 'TEST', |
| 176 | suite: failure.suiteName, |
| 177 | test: failure.testName, |
| 178 | message: failure.message, |
| 179 | location: failure.location, |
| 180 | durationMs: failure.durationMs, |
| 181 | }); |
| 182 | } |
| 183 | |
| 184 | function queueFailureDiagnostic(failure: { |
no outgoing calls