()
| 12 | } |
| 13 | |
| 14 | function main() { |
| 15 | const runtimeIds = listRuntimeIds(); |
| 16 | if (!runtimeIds.includes('claude-code') || !runtimeIds.includes('codex') || !runtimeIds.includes('unknown')) { |
| 17 | fail('Runtime registry missing one or more expected runtime ids'); |
| 18 | } |
| 19 | |
| 20 | if (!VALID_RUNTIMES.includes('codex')) { |
| 21 | fail('Detect-runtime valid runtime list missing codex'); |
| 22 | } |
| 23 | |
| 24 | const claude = getRuntimeDefinition('claude-code'); |
| 25 | const codex = getRuntimeDefinition('codex'); |
| 26 | const unknown = getRuntimeDefinition('does-not-exist'); |
| 27 | |
| 28 | if (claude.id !== 'claude-code') fail('Claude runtime definition mismatch'); |
| 29 | if (codex.id !== 'codex') fail('Codex runtime definition mismatch'); |
| 30 | if (unknown.id !== 'unknown') fail('Unknown runtime fallback mismatch'); |
| 31 | if (claude.capabilities.hooks.support !== 'full') fail('Claude runtime hooks capability mismatch'); |
| 32 | if (codex.capabilities.hooks.support === 'full') fail('Codex runtime hooks support should not be full'); |
| 33 | |
| 34 | const origEnv = process.env.CITADEL_RUNTIME; |
| 35 | process.env.CITADEL_RUNTIME = 'codex'; |
| 36 | const detected = detectRuntime('/nonexistent'); |
| 37 | if (detected.runtime !== 'codex' || detected.method !== 'env') { |
| 38 | fail(`Runtime detection env override mismatch: ${detected.runtime}/${detected.method}`); |
| 39 | } |
| 40 | if (origEnv !== undefined) process.env.CITADEL_RUNTIME = origEnv; |
| 41 | else delete process.env.CITADEL_RUNTIME; |
| 42 | |
| 43 | console.log('Runtime registry tests pass.'); |
| 44 | } |
| 45 | |
| 46 | main(); |
no test coverage detected