fix(opencode): normalize CLI test line endings

This commit is contained in:
Dax Raad 2026-06-22 19:15:26 -04:00
commit 23fd5907be

View file

@ -237,8 +237,8 @@ export function withCliFixture<A, E>(
) )
return { return {
exitCode: result.exitCode, exitCode: result.exitCode,
stdout: result.stdout.toString(), stdout: normalizeLines(result.stdout.toString()),
stderr: result.stderr.toString(), stderr: normalizeLines(result.stderr.toString()),
durationMs: Date.now() - start, durationMs: Date.now() - start,
} }
}) })
@ -299,8 +299,8 @@ export function withCliFixture<A, E>(
interrupt: () => proc.kill("SIGINT"), interrupt: () => proc.kill("SIGINT"),
result: Effect.promise(async () => ({ result: Effect.promise(async () => ({
exitCode: await proc.exited, exitCode: await proc.exited,
stdout: await stdout, stdout: normalizeLines(await stdout),
stderr: await stderr, stderr: normalizeLines(await stderr),
durationMs: Date.now() - start, durationMs: Date.now() - start,
})), })),
} satisfies RunHandle } satisfies RunHandle
@ -479,6 +479,10 @@ function parseJsonEvents(stdout: string): Array<Record<string, unknown>> {
.map((line) => JSON.parse(line) as Record<string, unknown>) .map((line) => JSON.parse(line) as Record<string, unknown>)
} }
function normalizeLines(value: string) {
return value.replaceAll("\r\n", "\n")
}
// Convenience for the common assertion pattern. Dumps stderr/stdout when // Convenience for the common assertion pattern. Dumps stderr/stdout when
// the exit code doesn't match — saves debugging time on CI failures. // the exit code doesn't match — saves debugging time on CI failures.
function expectExit(result: RunResult, expected: number, label = "opencode") { function expectExit(result: RunResult, expected: number, label = "opencode") {