mirror of
https://github.com/openai/codex.git
synced 2026-04-26 23:55:25 +00:00
Expand exec process shared flow coverage
Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
@@ -110,6 +110,26 @@ async fn assert_exec_process_terminates_running_process(use_remote: bool) -> Res
|
||||
let terminate = context.process.terminate("proc-io").await?;
|
||||
assert_eq!(terminate, TerminateResponse { running: true });
|
||||
|
||||
let mut next_seq = 0;
|
||||
loop {
|
||||
let read = context
|
||||
.process
|
||||
.read(ReadParams {
|
||||
process_id: "proc-io".to_string(),
|
||||
after_seq: Some(next_seq),
|
||||
max_bytes: None,
|
||||
wait_ms: Some(100),
|
||||
})
|
||||
.await?;
|
||||
next_seq = read.next_seq;
|
||||
if read.exited {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let terminate_after_exit = context.process.terminate("proc-io").await?;
|
||||
assert_eq!(terminate_after_exit, TerminateResponse { running: false });
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -119,3 +139,50 @@ async fn assert_exec_process_terminates_running_process(use_remote: bool) -> Res
|
||||
async fn exec_process_terminates_running_process(use_remote: bool) -> Result<()> {
|
||||
assert_exec_process_terminates_running_process(use_remote).await
|
||||
}
|
||||
|
||||
async fn assert_exec_process_read_returns_one_chunk_when_max_bytes_is_zero(
|
||||
use_remote: bool,
|
||||
) -> Result<()> {
|
||||
let context = create_process_context(use_remote).await?;
|
||||
let response = context
|
||||
.process
|
||||
.start(ExecParams {
|
||||
process_id: "proc-truncate".to_string(),
|
||||
argv: vec!["sh".to_string(), "-c".to_string(), "printf a".to_string()],
|
||||
cwd: std::env::current_dir()?,
|
||||
env: Default::default(),
|
||||
tty: false,
|
||||
arg0: None,
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(
|
||||
response,
|
||||
ExecResponse {
|
||||
process_id: "proc-truncate".to_string(),
|
||||
}
|
||||
);
|
||||
|
||||
let read = context
|
||||
.process
|
||||
.read(ReadParams {
|
||||
process_id: "proc-truncate".to_string(),
|
||||
after_seq: Some(0),
|
||||
max_bytes: Some(0),
|
||||
wait_ms: Some(100),
|
||||
})
|
||||
.await?;
|
||||
assert_eq!(read.chunks.len(), 1);
|
||||
assert_eq!(read.chunks[0].chunk.0, b"a");
|
||||
assert_eq!(read.next_seq, 2);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test_case(false ; "local")]
|
||||
#[test_case(true ; "remote")]
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
||||
async fn exec_process_read_returns_one_chunk_when_max_bytes_is_zero(
|
||||
use_remote: bool,
|
||||
) -> Result<()> {
|
||||
assert_exec_process_read_returns_one_chunk_when_max_bytes_is_zero(use_remote).await
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user