Skip to content

Commit 40f0d2b

Browse files
cpcloudclaude
andcommitted
test(agent/opencode): verify stderr preserved in error on non-zero exit
The prior commit disabled live stderr streaming for opencode, relying on runStreamingCLI's captured Stderr being surfaced through formatDetailedCLIWaitError when the process exits non-zero. Add a regression test that drives a non-zero exit with a real error line on stderr and asserts the line appears in the returned error message, locking in the failure-visibility guarantee. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ea92592 commit 40f0d2b

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

internal/agent/opencode_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,36 @@ func TestOpenCodeReviewStderrNotStreamedToOutput(t *testing.T) {
223223
assertNotContains(t, outStr, "warning: something")
224224
}
225225

226+
func TestOpenCodeReviewStderrPreservedInError(t *testing.T) {
227+
t.Parallel()
228+
skipIfWindows(t)
229+
230+
// StreamStderr is disabled for opencode, so stderr does not
231+
// appear in the live log on success. On non-zero exit the
232+
// captured stderr must still reach the user via the returned
233+
// error, otherwise failure diagnostics would be lost.
234+
stdoutLines := []string{makeTextEvent("Partial review")}
235+
stderrLines := []string{
236+
"Performing one time database migration, may take a few minutes...",
237+
"sqlite-migration:done",
238+
"Error: authentication token expired",
239+
}
240+
241+
_, _, _, err := executeReviewTest(t, reviewTestOpts{
242+
MockOpts: MockCLIOpts{
243+
CaptureStdin: true,
244+
StdoutLines: stdoutLines,
245+
StderrLines: stderrLines,
246+
ExitCode: 1,
247+
},
248+
Prompt: "prompt",
249+
})
250+
require.Error(t, err)
251+
252+
msg := err.Error()
253+
assertContains(t, msg, "Error: authentication token expired")
254+
}
255+
226256
func TestOpenCodeReviewNilOutput(t *testing.T) {
227257
t.Parallel()
228258
skipIfWindows(t)

0 commit comments

Comments
 (0)