Files
orca/src/shared/omp-fresh-launch-shell.test.ts
T
Neil 1912c90141 Extract subprocess handling into @orca/process-host (#26963)
Extract subprocess execution and process contracts into @orca/process-host with explicit public entry points, independent checks, and one Node 18 compatible CommonJS runtime. Migrate application consumers and integrate package builds, dependency selection, import enforcement, and runtime resource staging.

Preserve daemon startup ownership and profile isolation, and qualify development rebuild recovery and concurrent output publication. Remove unnecessary aliases, test forwarding exports, and a duplicate output scan.

Validation: full typechecks, changed-code quality, package and artifact checks, native Windows builds/types plus 306 runtime tests, and independent native reviews.

Matched full E2E controls on original main and unchanged reviewed head both pass all 17 applicable tests (nine skips). Earlier intermittent E2E failures are documented in the PR; no assertions were weakened. The final combined-tree audit preserves both branches with no import-boundary violations.
2026-10-09 18:32:28 -07:00

74 lines
2.7 KiB
TypeScript

import { existsSync } from 'node:fs'
import { mkdtemp, writeFile, readFile, rm } from 'node:fs/promises'
import { tmpdir } from 'node:os'
import { delimiter, join } from 'node:path'
import { afterEach, expect, it } from 'vitest'
import { runProcess } from '@orca/process-host'
import { buildAgentStartupPlan } from './tui-agent-startup'
const roots: string[] = []
afterEach(async () => {
for (const root of roots.splice(0)) {
await rm(root, { recursive: true, force: true })
}
})
const shells = ['bash', 'zsh', 'fish'].filter(
(shell) =>
process.platform !== 'win32' &&
(process.env.PATH ?? '')
.split(delimiter)
.some((directory) => existsSync(join(directory, shell)))
)
it.each(shells)(
'preserves same-shell function argv, one launch and exit status in %s',
async (shell) => {
const root = await mkdtemp(join(tmpdir(), 'orca-fresh-shell-'))
roots.push(root)
const config = join(root, 'fresh settings.yml')
const capture = join(root, 'argv')
await writeFile(config, 'autoResume: false\n')
const plan = buildAgentStartupPlan({
agent: 'omp',
prompt: 'task with spaces',
cmdOverrides: {},
platform: 'linux',
isRemote: true
})
expect(plan).not.toBeNull()
const define =
shell === 'fish'
? 'function omp; printf "%s\\n" $argv >> "$CAPTURE"; return 17; end; '
: 'omp() { printf "%s\\n" "$@" >> "$CAPTURE"; return 17; }; '
const result = await runProcess({
program: shell,
args: ['-c', define + plan!.launchCommand],
cwd: root,
env: { ...process.env, ORCA_OMP_FRESH_CONFIG: config, CAPTURE: capture }
})
expect(result.code).toBe(17)
expect(await readFile(capture, 'utf8')).toBe(`--config\n${config}\ntask with spaces\n`)
await rm(capture)
await rm(config)
const missing = await runProcess({
program: shell,
args: ['-c', define + plan!.launchCommand],
cwd: root,
env: { ...process.env, ORCA_OMP_FRESH_CONFIG: config, CAPTURE: capture }
})
expect(missing.code).not.toBe(0)
expect(missing.stderr).toContain('fresh OMP settings are unavailable')
await expect(readFile(capture)).rejects.toMatchObject({ code: 'ENOENT' })
const unsetEnv: NodeJS.ProcessEnv = { ...process.env, CAPTURE: capture }
delete unsetEnv.ORCA_OMP_FRESH_CONFIG
const unset = await runProcess({
program: shell,
args: ['-c', (shell === 'fish' ? '' : 'set -u; ') + define + plan!.launchCommand],
cwd: root,
env: unsetEnv
})
expect(unset.code).not.toBe(0)
expect(unset.stderr).toContain('fresh OMP settings are unavailable')
await expect(readFile(capture)).rejects.toMatchObject({ code: 'ENOENT' })
}
)