mirror of
https://github.com/openai/codex.git
synced 2026-04-24 14:45:27 +00:00
Add Rust CLI test
This commit is contained in:
3
codex-rs/Cargo.lock
generated
3
codex-rs/Cargo.lock
generated
@@ -669,14 +669,17 @@ name = "codex-exec"
|
||||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"assert_cmd",
|
||||
"chrono",
|
||||
"clap",
|
||||
"codex-common",
|
||||
"codex-core",
|
||||
"codex-linux-sandbox",
|
||||
"owo-colors",
|
||||
"predicates",
|
||||
"serde_json",
|
||||
"shlex",
|
||||
"tempfile",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
|
||||
@@ -37,3 +37,8 @@ tokio = { version = "1", features = [
|
||||
] }
|
||||
tracing = { version = "0.1.41", features = ["log"] }
|
||||
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
|
||||
|
||||
[dev-dependencies]
|
||||
assert_cmd = "2"
|
||||
predicates = "3"
|
||||
tempfile = "3"
|
||||
|
||||
29
codex-rs/exec/tests/tool_invocation.rs
Normal file
29
codex-rs/exec/tests/tool_invocation.rs
Normal file
@@ -0,0 +1,29 @@
|
||||
#![allow(clippy::unwrap_used, clippy::expect_used)]
|
||||
|
||||
use codex_core::exec::{ExecParams, SandboxType, process_exec_tool_call};
|
||||
use codex_core::protocol::SandboxPolicy;
|
||||
use std::collections::HashMap;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Notify;
|
||||
|
||||
#[tokio::test]
|
||||
async fn echo_command_outputs_text() {
|
||||
let params = ExecParams {
|
||||
command: vec!["echo".into(), "Hello".into()],
|
||||
cwd: std::env::current_dir().unwrap(),
|
||||
timeout_ms: None,
|
||||
env: HashMap::new(),
|
||||
};
|
||||
let policy = SandboxPolicy::new_workspace_write_policy();
|
||||
let output = process_exec_tool_call(
|
||||
params,
|
||||
SandboxType::None,
|
||||
Arc::new(Notify::new()),
|
||||
&policy,
|
||||
&None,
|
||||
)
|
||||
.await
|
||||
.expect("exec failed");
|
||||
assert_eq!(output.exit_code, 0);
|
||||
assert!(output.stdout.contains("Hello"));
|
||||
}
|
||||
Reference in New Issue
Block a user