Lightweight coding agent that runs in your terminal
Rust
fix: enable clippy on tests (#870)
Michael Bolina9adb4175c8f
diff --git a/.github/workflows/rust-ci.yml b/.github/workflows/rust-ci.ymlindex 21c0f7930a..06963dcdaa 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 errorsdiff --git a/codex-rs/core/src/is_safe_command.rs b/codex-rs/core/src/is_safe_command.rsindex b4d8f8c064..5c688bacf1 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<String> {diff --git a/codex-rs/core/src/linux.rs b/codex-rs/core/src/linux.rsindex 5ab579339d..9928cfee4e 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.rsindex f6512e8131..81e1983392 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.rsindex ac1b30a6d8..8417bf0c5d 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.rsindex 0a3cb49e78..e7479f89cd 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.rsindex 6d7d6085b0..5eb275b41d 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<Codex, CodexErr> {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.rsindex 20820c5233..5561abb8c1 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.rsindex 50c1ba39ea..0c4428b84b 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 serverlet server = MockServer::start().await;diff --git a/codex-rs/core/tests/stream_no_completed.rs b/codex-rs/core/tests/stream_no_completed.rsindex 1af5fc4a56..abb3d3ca30 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.rsindex 242ea6d177..3c9084e825 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.rsindex 3562bdbe2f..d843ac7d51 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.rsindex 7e11315729..dfd7cfd0bd 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()],}