* Validate the `--timeout` flag value. Returns a clamped integer in * range [1, 3600], or the default when absent.
(raw: string | undefined, flagName: string)
| 4462 | * range [1, 3600], or the default when absent. |
| 4463 | */ |
| 4464 | function parseTimeoutFlag(raw: string | undefined, flagName: string): number { |
| 4465 | if (raw === undefined) return DEFAULT_RUN_TIMEOUT_SECONDS; |
| 4466 | const n = Number(raw); |
| 4467 | if (!Number.isFinite(n) || !Number.isInteger(n) || n < 1) { |
| 4468 | throw localValidationError( |
| 4469 | flagName, |
| 4470 | `must be an integer between 1 and ${MAX_RUN_TIMEOUT_SECONDS}`, |
| 4471 | ); |
| 4472 | } |
| 4473 | if (n > MAX_RUN_TIMEOUT_SECONDS) { |
| 4474 | throw localValidationError(flagName, `must be at most ${MAX_RUN_TIMEOUT_SECONDS} seconds`); |
| 4475 | } |
| 4476 | return n; |
| 4477 | } |
| 4478 | |
| 4479 | /** |
| 4480 | * `test run <test-id>` — M3.3 piece-3. |
no test coverage detected