MCPcopy Create free account
hub / github.com/github/copilot-sdk / TestMonitorProcess_StderrCaptured

Function TestMonitorProcess_StderrCaptured

go/client_test.go:2514–2545  ·  view source on GitHub ↗

TestMonitorProcess_StderrCaptured validates that when the CLI process writes an error to stderr and exits, the stderr content IS included in the process error (now that startCLIServer sets Stderr).

(t *testing.T)

Source from the content-addressed store, hash-verified

2512// writes an error to stderr and exits, the stderr content IS included
2513// in the process error (now that startCLIServer sets Stderr).
2514func TestMonitorProcess_StderrCaptured(t *testing.T) {
2515 client := &Client{
2516 sessions: make(map[string]*Session),
2517 }
2518
2519 stderrMsg := "error: authentication failed: invalid token"
2520 client.process = exec.Command(os.Args[0], "-test.run=TestHelperProcess", "--", stderrMsg)
2521 client.process.Env = append(os.Environ(), "GO_WANT_HELPER_PROCESS=1")
2522
2523 // Replicate what startCLIServer now does: capture stderr.
2524 client.process.Stderr = truncbuffer.NewTruncBuffer(stderrBufferSize)
2525
2526 if err := client.process.Start(); err != nil {
2527 t.Fatalf("failed to start test process: %v", err)
2528 }
2529
2530 client.monitorProcess()
2531
2532 // Wait for the process to exit.
2533 <-client.processDone
2534
2535 processError := *client.processErrorPtr
2536 if processError == nil {
2537 t.Fatal("expected a process error after non-zero exit, got nil")
2538 }
2539
2540 if !strings.Contains(processError.Error(), stderrMsg) {
2541 t.Errorf("stderr output not included in process error.\n"+
2542 " got: %q\n"+
2543 " want: error containing %q", processError.Error(), stderrMsg)
2544 }
2545}
2546
2547// TestMonitorProcess_StderrCapturedOnZeroExit validates that even when the
2548// CLI process exits with code 0, stderr content is included in the error.

Callers

nothing calls this directly

Calls 3

monitorProcessMethod · 0.95
StartMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…