Skip to content

Commit 1b937c8

Browse files
test(opencode): align unknown finish coverage (#43895)
Co-authored-by: thdxr <[email protected]>
1 parent ad0bb6d commit 1b937c8

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

‎packages/opencode/test/cli/run/run-process.test.ts‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,10 @@ describe("opencode run (non-interactive subprocess)", () => {
8282
)
8383

8484
// The test provider's SSE error item is interpreted by the SDK as an unknown
85-
// finish, not a fatal provider/session error. Lock that distinction in so it
86-
// is not accidentally used as the failure compatibility oracle.
85+
// finish, not a fatal provider/session error. Unknown finishes should continue
86+
// the prompt loop so a subsequent response can complete the run.
8787
cliIt.concurrent(
88-
"unknown stream finish preserves partial output and exits 0",
88+
"unknown stream finish preserves partial output and continues",
8989
({ llm, opencode }) =>
9090
Effect.gen(function* () {
9191
yield* llm.push(
@@ -95,9 +95,10 @@ describe("opencode run (non-interactive subprocess)", () => {
9595
}),
9696
)
9797
yield* llm.fail("upstream provider exploded mid-stream")
98+
yield* llm.text("recovered")
9899
const result = yield* opencode.run("trigger midstream error", { timeoutMs: 30_000 })
99100
expect(result.exitCode).toBe(0)
100-
expect(result.stdout).toBe("partial response\n")
101+
expect(result.stdout).toBe("partial response\nrecovered\n")
101102
expect(result.stderr).not.toContain("upstream provider exploded mid-stream")
102103
}),
103104
60_000,
@@ -213,7 +214,7 @@ describe("opencode run (non-interactive subprocess)", () => {
213214
)
214215

215216
cliIt.concurrent(
216-
"--format json records partial output for an unknown stream finish",
217+
"--format json records an unknown stream finish and continuation",
217218
({ llm, opencode }) =>
218219
Effect.gen(function* () {
219220
yield* llm.push(
@@ -223,6 +224,7 @@ describe("opencode run (non-interactive subprocess)", () => {
223224
}),
224225
)
225226
yield* llm.fail("provider failed")
227+
yield* llm.text("recovered")
226228
const result = yield* opencode.run("fail after output", { format: "json" })
227229

228230
const events = opencode.parseJsonEvents(result.stdout)
@@ -234,9 +236,14 @@ describe("opencode run (non-interactive subprocess)", () => {
234236
"step_finish",
235237
"step_start",
236238
"step_finish",
239+
"step_start",
240+
"text",
241+
"step_finish",
237242
])
238243
expect(events[1]?.part).toEqual(expect.objectContaining({ type: "text", text: "partial json" }))
239-
expect(events.at(-1)?.part).toEqual(expect.objectContaining({ type: "step-finish", reason: "unknown" }))
244+
expect(events[5]?.part).toEqual(expect.objectContaining({ type: "step-finish", reason: "unknown" }))
245+
expect(events[7]?.part).toEqual(expect.objectContaining({ type: "text", text: "recovered" }))
246+
expect(events.at(-1)?.part).toEqual(expect.objectContaining({ type: "step-finish", reason: "stop" }))
240247
}),
241248
60_000,
242249
)

0 commit comments

Comments
 (0)