(options: {
readonly prefix: string
readonly wrapperPath: string
readonly envFactory: (
configDir: string,
tmpDir: string,
) => Promise<NodeJS.ProcessEnv>
readonly expectedRows: readonly string[]
readonly cwd?: string
readonly height?: number
readonly startupTimeoutMs?: number
readonly startupBudgetMs?: number
})
| 56 | } |
| 57 | |
| 58 | function createFixture(options: { |
| 59 | readonly prefix: string |
| 60 | readonly wrapperPath: string |
| 61 | readonly envFactory: ( |
| 62 | configDir: string, |
| 63 | tmpDir: string, |
| 64 | ) => Promise<NodeJS.ProcessEnv> |
| 65 | readonly expectedRows: readonly string[] |
| 66 | readonly cwd?: string |
| 67 | readonly height?: number |
| 68 | readonly startupTimeoutMs?: number |
| 69 | readonly startupBudgetMs?: number |
| 70 | }): Promise<WrapperTmuxFixture> { |
| 71 | const tmpDir = mkdtempSync(join(tmpdir(), options.prefix)) |
| 72 | const configDir = join(tmpDir, 'config') |
| 73 | const launchScriptPath = join(tmpDir, 'launch-wrapper.sh') |
| 74 | mkdirSync(configDir, { recursive: true }) |
| 75 | return options.envFactory(configDir, tmpDir).then(env => { |
| 76 | writeEnvLaunchScript( |
| 77 | launchScriptPath, |
| 78 | options.wrapperPath, |
| 79 | options.cwd ?? WRAPPER_HARNESS_REPO_ROOT, |
| 80 | env, |
| 81 | ) |
| 82 | |
| 83 | const startedAt = Date.now() |
| 84 | const session = createIsolatedTmuxSession({ |
| 85 | command: `bash ${shellQuote(launchScriptPath)}`, |
| 86 | width: 120, |
| 87 | height: options.height ?? 40, |
| 88 | }) |
| 89 | |
| 90 | return { |
| 91 | tmpDir, |
| 92 | configDir, |
| 93 | session, |
| 94 | cwd: options.cwd ?? WRAPPER_HARNESS_REPO_ROOT, |
| 95 | startupTimeoutMs: options.startupTimeoutMs ?? 25_000, |
| 96 | startupBudgetMs: options.startupBudgetMs ?? 18_000, |
| 97 | expectedRows: options.expectedRows, |
| 98 | getElapsedMs() { |
| 99 | return Date.now() - startedAt |
| 100 | }, |
| 101 | cleanup() { |
| 102 | destroyIsolatedTmuxSession(session) |
| 103 | rmSync(tmpDir, { recursive: true, force: true }) |
| 104 | }, |
| 105 | } |
| 106 | }) |
| 107 | } |
| 108 | |
| 109 | export async function waitForWrapperTmuxRows( |
| 110 | fixture: WrapperTmuxFixture, |
no test coverage detected