diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.yml index 21c0f793..06963dcd 100644 --- a/.github/workflows/rust-ci.yml +++ b/.github/workflows/rust-ci.yml @@ -81,7 +81,7 @@ jobs: run: echo "FAILED=" >> $GITHUB_ENV - name: cargo clippy - run: cargo clippy --target ${{ matrix.target }} --all-features -- -D warnings || echo "FAILED=${FAILED:+$FAILED, }cargo clippy" >> $GITHUB_ENV + run: cargo clippy --target ${{ matrix.target }} --all-features --tests -- -D warnings || echo "FAILED=${FAILED:+$FAILED, }cargo clippy" >> $GITHUB_ENV # Running `cargo build` from the workspace root builds the workspace using # the union of all features from third-party crates. This can mask errors diff --git a/codex-rs/core/src/is_safe_command.rs b/codex-rs/core/src/is_safe_command.rs index b4d8f8c0..5c688bac 100644 --- a/codex-rs/core/src/is_safe_command.rs +++ b/codex-rs/core/src/is_safe_command.rs @@ -194,6 +194,7 @@ fn is_valid_sed_n_arg(arg: Option<&str>) -> bool { } #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] use super::*; fn vec_str(args: &[&str]) -> Vec { diff --git a/codex-rs/core/src/linux.rs b/codex-rs/core/src/linux.rs index 5ab57933..9928cfee 100644 --- a/codex-rs/core/src/linux.rs +++ b/codex-rs/core/src/linux.rs @@ -179,7 +179,9 @@ fn install_network_seccomp_filter_on_current_thread() -> std::result::Result<(), } #[cfg(test)] -mod tests_linux { +mod tests { + #![allow(clippy::unwrap_used)] + use super::*; use crate::exec::ExecParams; use crate::exec::SandboxType; diff --git a/codex-rs/core/src/models.rs b/codex-rs/core/src/models.rs index f6512e81..81e19833 100644 --- a/codex-rs/core/src/models.rs +++ b/codex-rs/core/src/models.rs @@ -163,6 +163,7 @@ impl std::ops::Deref for FunctionCallOutputPayload { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] use super::*; #[test] diff --git a/codex-rs/core/src/safety.rs b/codex-rs/core/src/safety.rs index ac1b30a6..8417bf0c 100644 --- a/codex-rs/core/src/safety.rs +++ b/codex-rs/core/src/safety.rs @@ -189,6 +189,7 @@ fn is_write_patch_constrained_to_writable_paths( #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] use super::*; #[test] diff --git a/codex-rs/core/src/user_notification.rs b/codex-rs/core/src/user_notification.rs index 0a3cb49e..e7479f89 100644 --- a/codex-rs/core/src/user_notification.rs +++ b/codex-rs/core/src/user_notification.rs @@ -20,6 +20,7 @@ pub(crate) enum UserNotification { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] use super::*; #[test] diff --git a/codex-rs/core/tests/live_agent.rs b/codex-rs/core/tests/live_agent.rs index 6d7d6085..5eb275b4 100644 --- a/codex-rs/core/tests/live_agent.rs +++ b/codex-rs/core/tests/live_agent.rs @@ -19,6 +19,7 @@ use std::time::Duration; use codex_core::Codex; use codex_core::config::Config; +use codex_core::error::CodexErr; use codex_core::protocol::EventMsg; use codex_core::protocol::InputItem; use codex_core::protocol::Op; @@ -32,7 +33,7 @@ fn api_key_available() -> bool { /// Helper that spawns a fresh Agent and sends the mandatory *ConfigureSession* /// submission. The caller receives the constructed [`Agent`] plus the unique /// submission id used for the initialization message. -async fn spawn_codex() -> Codex { +async fn spawn_codex() -> Result { assert!( api_key_available(), "OPENAI_API_KEY must be set for live tests" @@ -53,11 +54,9 @@ async fn spawn_codex() -> Codex { } let config = Config::load_default_config_for_test(); - let (agent, _init_id) = Codex::spawn(config, std::sync::Arc::new(Notify::new())) - .await - .unwrap(); + let (agent, _init_id) = Codex::spawn(config, std::sync::Arc::new(Notify::new())).await?; - agent + Ok(agent) } /// Verifies that the agent streams incremental *AgentMessage* events **before** @@ -66,12 +65,13 @@ async fn spawn_codex() -> Codex { #[ignore] #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn live_streaming_and_prev_id_reset() { + #![allow(clippy::unwrap_used)] if !api_key_available() { eprintln!("skipping live_streaming_and_prev_id_reset – OPENAI_API_KEY not set"); return; } - let codex = spawn_codex().await; + let codex = spawn_codex().await.unwrap(); // ---------- Task 1 ---------- codex @@ -140,12 +140,13 @@ async fn live_streaming_and_prev_id_reset() { #[ignore] #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn live_shell_function_call() { + #![allow(clippy::unwrap_used)] if !api_key_available() { eprintln!("skipping live_shell_function_call – OPENAI_API_KEY not set"); return; } - let codex = spawn_codex().await; + let codex = spawn_codex().await.unwrap(); const MARKER: &str = "codex_live_echo_ok"; diff --git a/codex-rs/core/tests/live_cli.rs b/codex-rs/core/tests/live_cli.rs index 20820c52..5561abb8 100644 --- a/codex-rs/core/tests/live_cli.rs +++ b/codex-rs/core/tests/live_cli.rs @@ -15,6 +15,7 @@ fn require_api_key() -> String { /// Helper that spawns the binary inside a TempDir with minimal flags. Returns (Assert, TempDir). fn run_live(prompt: &str) -> (assert_cmd::assert::Assert, TempDir) { + #![allow(clippy::unwrap_used)] use std::io::Read; use std::io::Write; use std::thread; @@ -110,6 +111,7 @@ fn run_live(prompt: &str) -> (assert_cmd::assert::Assert, TempDir) { #[ignore] #[test] fn live_create_file_hello_txt() { + #![allow(clippy::unwrap_used)] if std::env::var("OPENAI_API_KEY").is_err() { eprintln!("skipping live_create_file_hello_txt – OPENAI_API_KEY not set"); return; diff --git a/codex-rs/core/tests/previous_response_id.rs b/codex-rs/core/tests/previous_response_id.rs index 50c1ba39..0c4428b8 100644 --- a/codex-rs/core/tests/previous_response_id.rs +++ b/codex-rs/core/tests/previous_response_id.rs @@ -48,6 +48,8 @@ data: {{\"type\":\"response.completed\",\"response\":{{\"id\":\"{}\",\"output\": #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn keeps_previous_response_id_between_tasks() { + #![allow(clippy::unwrap_used)] + // Mock server let server = MockServer::start().await; diff --git a/codex-rs/core/tests/stream_no_completed.rs b/codex-rs/core/tests/stream_no_completed.rs index 1af5fc4a..abb3d3ca 100644 --- a/codex-rs/core/tests/stream_no_completed.rs +++ b/codex-rs/core/tests/stream_no_completed.rs @@ -32,6 +32,8 @@ data: {{\"type\":\"response.completed\",\"response\":{{\"id\":\"{}\",\"output\": #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn retries_on_early_close() { + #![allow(clippy::unwrap_used)] + let server = MockServer::start().await; struct SeqResponder; diff --git a/codex-rs/execpolicy/src/execv_checker.rs b/codex-rs/execpolicy/src/execv_checker.rs index 242ea6d1..3c9084e8 100644 --- a/codex-rs/execpolicy/src/execv_checker.rs +++ b/codex-rs/execpolicy/src/execv_checker.rs @@ -140,6 +140,7 @@ fn is_executable_file(path: &str) -> bool { #[cfg(test)] mod tests { + #![allow(clippy::unwrap_used)] use tempfile::TempDir; use super::*; diff --git a/codex-rs/execpolicy/tests/head.rs b/codex-rs/execpolicy/tests/head.rs index 3562bdbe..d843ac7d 100644 --- a/codex-rs/execpolicy/tests/head.rs +++ b/codex-rs/execpolicy/tests/head.rs @@ -67,7 +67,10 @@ fn test_head_one_flag_one_file() -> Result<()> { exec: ValidExec { program: "head".to_string(), flags: vec![], - opts: vec![MatchedOpt::new("-n", "100", ArgType::PositiveInteger).unwrap()], + opts: vec![ + MatchedOpt::new("-n", "100", ArgType::PositiveInteger) + .expect("should validate") + ], args: vec![MatchedArg::new( 2, ArgType::ReadableFile, diff --git a/codex-rs/execpolicy/tests/sed.rs b/codex-rs/execpolicy/tests/sed.rs index 7e113157..dfd7cfd0 100644 --- a/codex-rs/execpolicy/tests/sed.rs +++ b/codex-rs/execpolicy/tests/sed.rs @@ -47,7 +47,10 @@ fn test_sed_print_specific_lines_with_e_flag() -> Result<()> { exec: ValidExec { program: "sed".to_string(), flags: vec![MatchedFlag::new("-n")], - opts: vec![MatchedOpt::new("-e", "122,202p", ArgType::SedCommand).unwrap()], + opts: vec![ + MatchedOpt::new("-e", "122,202p", ArgType::SedCommand) + .expect("should validate") + ], args: vec![MatchedArg::new(3, ArgType::ReadableFile, "hello.txt")?], system_path: vec!["/usr/bin/sed".to_string()], }