mirror of
https://github.com/openai/codex.git
synced 2026-11-13 06:45:07 +00:00
chore: print stderr from MCP server to test output using eprintln! (#2849)
Related to https://github.com/openai/codex/pull/2848, I don't see the stderr from `codex mcp` colocated with the other stderr from `test_shell_command_approval_triggers_elicitation()` when it fails even though we have `RUST_LOG=debug` set when we spawn `codex mcp`: https://github.com/openai/codex/blob/1e9e703b969d3f0965b31d1cc3d70fed3ebdd6f6/codex-rs/mcp-server/tests/common/mcp_process.rs#L65 Let's try this new logic which should be more explicit.
This commit is contained in:
1 parent
1e9e703b96
commit
f09170b574
1 file changed
+12
@@ -61,6 +61,7 @@ impl McpProcess {
|
|||||||
|
|
||||||
cmd.stdin(Stdio::piped());
|
cmd.stdin(Stdio::piped());
|
||||||
cmd.stdout(Stdio::piped());
|
cmd.stdout(Stdio::piped());
|
||||||
|
cmd.stderr(Stdio::piped());
|
||||||
cmd.env("CODEX_HOME", codex_home);
|
cmd.env("CODEX_HOME", codex_home);
|
||||||
cmd.env("RUST_LOG", "debug");
|
cmd.env("RUST_LOG", "debug");
|
||||||
|
|
||||||
@@ -77,6 +78,17 @@ impl McpProcess {
|
|||||||
.take()
|
.take()
|
||||||
.ok_or_else(|| anyhow::format_err!("mcp should have stdout fd"))?;
|
.ok_or_else(|| anyhow::format_err!("mcp should have stdout fd"))?;
|
||||||
let stdout = BufReader::new(stdout);
|
let stdout = BufReader::new(stdout);
|
||||||
|
|
||||||
|
// Forward child's stderr to our stderr so failures are visible even
|
||||||
|
// when stdout/stderr are captured by the test harness.
|
||||||
|
if let Some(stderr) = process.stderr.take() {
|
||||||
|
let mut stderr_reader = BufReader::new(stderr).lines();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
while let Ok(Some(line)) = stderr_reader.next_line().await {
|
||||||
|
eprintln!("[mcp stderr] {line}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
next_request_id: AtomicI64::new(0),
|
next_request_id: AtomicI64::new(0),
|
||||||
process,
|
process,
|
||||||
|
|||||||
Reference in new issue
Block a user