( result: Pick<ReturnType<typeof spawnSync>, 'error' | 'signal' | 'status' | 'stderr'>, label: string, )
| 69 | } |
| 70 | |
| 71 | export function assertCliSnapshotProcessResult( |
| 72 | result: Pick<ReturnType<typeof spawnSync>, 'error' | 'signal' | 'status' | 'stderr'>, |
| 73 | label: string, |
| 74 | ): void { |
| 75 | if (result.error) { |
| 76 | throw new Error(`CLI process failed for ${label}: ${result.error.message}`); |
| 77 | } |
| 78 | |
| 79 | if (result.signal) { |
| 80 | throw new Error(`CLI process for ${label} was terminated by signal ${result.signal}.`); |
| 81 | } |
| 82 | |
| 83 | if (result.status === null) { |
| 84 | throw new Error( |
| 85 | `CLI process exit status was null for ${label}; the process may have timed out or been killed by a signal.`, |
| 86 | ); |
| 87 | } |
| 88 | |
| 89 | const stderr = readProcessOutput(result.stderr).trim(); |
| 90 | if (stderr.length > 0) { |
| 91 | throw new Error(`CLI process emitted unexpected stderr for ${label}:\n${stderr}`); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | function parseStructuredEnvelope( |
| 96 | stdout: string, |
no test coverage detected