From 56f558dc1b4ad783db54926d16dc06da0f1bdf80 Mon Sep 17 00:00:00 2001 From: "Dhanji R. Prasanna" Date: Thu, 29 Jan 2026 11:15:10 +1100 Subject: [PATCH] Fix compiler warnings in test files Eliminate unused variable and import warnings across test files: - streaming_parser_test.rs: prefix unused `tools` with underscore - webdriver_session.rs: remove unused `use super::*` import - mock_provider_integration_test.rs: prefix unused `result` and `task_result` - test_preflight_max_tokens.rs: prefix unused `proposed_max` - todo_staleness_test.rs: add #[allow(dead_code)] for test helper methods - json_parsing_stress_test.rs: prefix unused `tools` - read_file_token_limit_test.rs: add #[allow(dead_code)] for unused helper - background_process_demo_test.rs: remove unused PathBuf import - test_session_continuation.rs: prefix unused `temp_dir` in 7 tests All tests pass. No behavior changes. Agent: fowler --- crates/g3-core/src/webdriver_session.rs | 2 -- .../g3-core/tests/background_process_demo_test.rs | 1 - crates/g3-core/tests/json_parsing_stress_test.rs | 2 +- .../tests/mock_provider_integration_test.rs | 4 ++-- crates/g3-core/tests/read_file_token_limit_test.rs | 1 + crates/g3-core/tests/streaming_parser_test.rs | 2 +- crates/g3-core/tests/test_preflight_max_tokens.rs | 2 +- crates/g3-core/tests/test_session_continuation.rs | 14 +++++++------- crates/g3-core/tests/todo_staleness_test.rs | 3 +++ 9 files changed, 16 insertions(+), 15 deletions(-) diff --git a/crates/g3-core/src/webdriver_session.rs b/crates/g3-core/src/webdriver_session.rs index dd6d847..a3d572f 100644 --- a/crates/g3-core/src/webdriver_session.rs +++ b/crates/g3-core/src/webdriver_session.rs @@ -120,8 +120,6 @@ impl WebDriverSession { #[cfg(test)] mod tests { - use super::*; - #[test] fn test_webdriver_session_enum_variants() { // This test just verifies the enum structure compiles correctly diff --git a/crates/g3-core/tests/background_process_demo_test.rs b/crates/g3-core/tests/background_process_demo_test.rs index 23dd3d3..a4feea8 100644 --- a/crates/g3-core/tests/background_process_demo_test.rs +++ b/crates/g3-core/tests/background_process_demo_test.rs @@ -1,5 +1,4 @@ use g3_core::background_process::BackgroundProcessManager; -use std::path::PathBuf; use std::thread; use std::time::Duration; use std::fs; diff --git a/crates/g3-core/tests/json_parsing_stress_test.rs b/crates/g3-core/tests/json_parsing_stress_test.rs index 4e048b3..2d1572d 100644 --- a/crates/g3-core/tests/json_parsing_stress_test.rs +++ b/crates/g3-core/tests/json_parsing_stress_test.rs @@ -164,7 +164,7 @@ fn test_json_in_indented_code_block() { That's it."#; - let tools = parser.process_chunk(&chunk(content)); + let _tools = parser.process_chunk(&chunk(content)); parser.process_chunk(&finished_chunk()); // Indented code blocks are trickier - the JSON is on its own line but indented diff --git a/crates/g3-core/tests/mock_provider_integration_test.rs b/crates/g3-core/tests/mock_provider_integration_test.rs index cd9a8b7..d737e34 100644 --- a/crates/g3-core/tests/mock_provider_integration_test.rs +++ b/crates/g3-core/tests/mock_provider_integration_test.rs @@ -331,7 +331,7 @@ async fn test_json_on_own_line_detected_as_tool() { // The task should detect the tool call // Note: This will fail because we don't have a real shell, but that's OK // We just want to verify the tool call was detected - let result = agent.execute_task("Run echo hello", None, false).await; + let _result = agent.execute_task("Run echo hello", None, false).await; // The result might be an error (tool execution fails in test env) // but we can check if a tool was attempted by looking at context @@ -408,7 +408,7 @@ async fn test_response_not_duplicated() { assert!(result.is_ok(), "Task should succeed: {:?}", result.err()); // Check the TaskResult - it should have the response - let task_result = result.unwrap(); + let _task_result = result.unwrap(); // The response field might be empty (content was streamed) or contain the response // Either way, the context should have exactly one assistant message with this content diff --git a/crates/g3-core/tests/read_file_token_limit_test.rs b/crates/g3-core/tests/read_file_token_limit_test.rs index 275b7fa..bddc903 100644 --- a/crates/g3-core/tests/read_file_token_limit_test.rs +++ b/crates/g3-core/tests/read_file_token_limit_test.rs @@ -8,6 +8,7 @@ use std::path::PathBuf; use tempfile::TempDir; /// Helper to create a test file with specified size +#[allow(dead_code)] fn create_test_file(dir: &TempDir, name: &str, size_bytes: usize) -> PathBuf { let path = dir.path().join(name); let content: String = "x".repeat(size_bytes); diff --git a/crates/g3-core/tests/streaming_parser_test.rs b/crates/g3-core/tests/streaming_parser_test.rs index 1e8aec0..97c0e41 100644 --- a/crates/g3-core/tests/streaming_parser_test.rs +++ b/crates/g3-core/tests/streaming_parser_test.rs @@ -75,7 +75,7 @@ fn test_first_complete_second_incomplete() { let content = r#"{"tool": "read_file", "args": {"file_path": "a.txt"}} {"tool": "shell", "args": {"command": "ls"#; - let tools = parser.process_chunk(&chunk(content, false)); + let _tools = parser.process_chunk(&chunk(content, false)); // Should detect the first complete tool call // The incomplete one should be detected by has_incomplete_tool_call diff --git a/crates/g3-core/tests/test_preflight_max_tokens.rs b/crates/g3-core/tests/test_preflight_max_tokens.rs index c4d94e1..b394071 100644 --- a/crates/g3-core/tests/test_preflight_max_tokens.rs +++ b/crates/g3-core/tests/test_preflight_max_tokens.rs @@ -34,7 +34,7 @@ fn test_no_thinking_budget_passes_through() { let config = create_test_config_with_thinking(None); // Without thinking budget, any max_tokens should be fine - let proposed_max = 5000; + let _proposed_max = 5000; // The constraint check would return (proposed_max, false) // since there's no thinking_budget_tokens configured diff --git a/crates/g3-core/tests/test_session_continuation.rs b/crates/g3-core/tests/test_session_continuation.rs index efcbfc1..10f6afd 100644 --- a/crates/g3-core/tests/test_session_continuation.rs +++ b/crates/g3-core/tests/test_session_continuation.rs @@ -125,7 +125,7 @@ fn test_find_incomplete_agent_session() { use g3_core::session_continuation::find_incomplete_agent_session; let _lock = TEST_MUTEX.lock().unwrap(); - let (temp_dir, original_dir) = setup_test_env(); + let (_temp_dir, original_dir) = setup_test_env(); // Get the actual current directory (after set_current_dir in setup) let current_working_dir = std::env::current_dir() @@ -165,7 +165,7 @@ fn test_find_incomplete_agent_session_ignores_complete_todos() { use g3_core::session_continuation::find_incomplete_agent_session; let _lock = TEST_MUTEX.lock().unwrap(); - let (temp_dir, original_dir) = setup_test_env(); + let (_temp_dir, original_dir) = setup_test_env(); let current_working_dir = std::env::current_dir() .map(|p| p.to_string_lossy().to_string()) @@ -197,7 +197,7 @@ fn test_find_incomplete_agent_session_ignores_non_agent_mode() { use g3_core::session_continuation::find_incomplete_agent_session; let _lock = TEST_MUTEX.lock().unwrap(); - let (temp_dir, original_dir) = setup_test_env(); + let (_temp_dir, original_dir) = setup_test_env(); let current_working_dir = std::env::current_dir() .map(|p| p.to_string_lossy().to_string()) @@ -227,7 +227,7 @@ fn test_find_incomplete_agent_session_ignores_non_agent_mode() { #[test] fn test_load_continuation_when_none_exists() { let _lock = TEST_MUTEX.lock().unwrap(); - let (temp_dir, original_dir) = setup_test_env(); + let (_temp_dir, original_dir) = setup_test_env(); // No continuation should exist in a fresh temp directory let result = load_continuation().expect("load_continuation should not error"); @@ -239,7 +239,7 @@ fn test_load_continuation_when_none_exists() { #[test] fn test_clear_continuation() { let _lock = TEST_MUTEX.lock().unwrap(); - let (temp_dir, original_dir) = setup_test_env(); + let (_temp_dir, original_dir) = setup_test_env(); // Create and save a continuation let continuation = SessionContinuation::new(false, None, @@ -295,7 +295,7 @@ fn test_ensure_session_dir_creates_g3_directory() { #[test] fn test_has_valid_continuation_with_missing_session_log() { let _lock = TEST_MUTEX.lock().unwrap(); - let (temp_dir, original_dir) = setup_test_env(); + let (_temp_dir, original_dir) = setup_test_env(); // Create a continuation pointing to a non-existent session log let continuation = SessionContinuation::new(false, None, @@ -347,7 +347,7 @@ fn test_has_valid_continuation_with_existing_session_log() { #[test] fn test_continuation_serialization_format() { let _lock = TEST_MUTEX.lock().unwrap(); - let (temp_dir, original_dir) = setup_test_env(); + let (_temp_dir, original_dir) = setup_test_env(); let continuation = SessionContinuation::new(false, None, "format_test".to_string(), diff --git a/crates/g3-core/tests/todo_staleness_test.rs b/crates/g3-core/tests/todo_staleness_test.rs index 177a33a..cbaf714 100644 --- a/crates/g3-core/tests/todo_staleness_test.rs +++ b/crates/g3-core/tests/todo_staleness_test.rs @@ -22,14 +22,17 @@ impl MockUiWriter { } } + #[allow(dead_code)] fn set_prompt_response(&self, response: bool) { self.prompt_responses.lock().unwrap().push(response); } + #[allow(dead_code)] fn set_choice_response(&self, response: usize) { self.choice_responses.lock().unwrap().push(response); } + #[allow(dead_code)] fn get_output(&self) -> Vec { self.output.lock().unwrap().clone() }