chore: enforce argument-comment lint across all targets

This commit is contained in:
Michael Bolin
2026-03-27 17:34:47 -07:00
parent f4f6eca871
commit f05597bbc0
307 changed files with 7720 additions and 4706 deletions
+5 -5
View File
@@ -151,18 +151,18 @@ mod tests {
let cache = BlockingLruCache::new(NonZeroUsize::new(2).expect("capacity"));
assert!(cache.get(&"first").is_none());
cache.insert("first", 1);
cache.insert("first", /*value*/ 1);
assert_eq!(cache.get(&"first"), Some(1));
}
#[tokio::test(flavor = "multi_thread")]
async fn evicts_least_recently_used() {
let cache = BlockingLruCache::new(NonZeroUsize::new(2).expect("capacity"));
cache.insert("a", 1);
cache.insert("b", 2);
cache.insert("a", /*value*/ 1);
cache.insert("b", /*value*/ 2);
assert_eq!(cache.get(&"a"), Some(1));
cache.insert("c", 3);
cache.insert("c", /*value*/ 3);
assert!(cache.get(&"b").is_none());
assert_eq!(cache.get(&"a"), Some(1));
@@ -172,7 +172,7 @@ mod tests {
#[test]
fn disabled_without_runtime() {
let cache = BlockingLruCache::new(NonZeroUsize::new(2).expect("capacity"));
cache.insert("first", 1);
cache.insert("first", /*value*/ 1);
assert!(cache.get(&"first").is_none());
assert_eq!(cache.get_or_insert_with("first", || 2), 2);
+5 -2
View File
@@ -26,7 +26,7 @@ mod tests {
#[test]
fn returns_dash_when_empty() {
assert_eq!(format_env_display(None, &[]), "-");
assert_eq!(format_env_display(/*env*/ None, &[]), "-");
let empty_map = HashMap::new();
assert_eq!(format_env_display(Some(&empty_map), &[]), "-");
@@ -45,7 +45,10 @@ mod tests {
fn formats_env_vars_with_dollar_prefix() {
let vars = vec!["TOKEN".to_string(), "PATH".to_string()];
assert_eq!(format_env_display(None, &vars), "TOKEN=*****, PATH=*****");
assert_eq!(
format_env_display(/*env*/ None, &vars),
"TOKEN=*****, PATH=*****"
);
}
#[test]
+2 -1
View File
@@ -120,7 +120,8 @@ mod tests {
#[test]
fn find_codex_home_without_env_uses_default_home_dir() {
let resolved = find_codex_home_from_env(None).expect("default CODEX_HOME");
let resolved =
find_codex_home_from_env(/*codex_home_env*/ None).expect("default CODEX_HOME");
let mut expected = home_dir().expect("home dir");
expected.push(".codex");
assert_eq!(resolved, expected);
@@ -29,7 +29,8 @@ mod wsl {
#[test]
fn wsl_mnt_drive_paths_lowercase() {
let normalized = normalize_for_wsl_with_flag(PathBuf::from("/mnt/C/Users/Dev"), true);
let normalized =
normalize_for_wsl_with_flag(PathBuf::from("/mnt/C/Users/Dev"), /*is_wsl*/ true);
assert_eq!(normalized, PathBuf::from("/mnt/c/users/dev"));
}
@@ -37,7 +38,7 @@ mod wsl {
#[test]
fn wsl_non_drive_paths_unchanged() {
let path = PathBuf::from("/mnt/cc/Users/Dev");
let normalized = normalize_for_wsl_with_flag(path.clone(), true);
let normalized = normalize_for_wsl_with_flag(path.clone(), /*is_wsl*/ true);
assert_eq!(normalized, path);
}
@@ -45,7 +46,7 @@ mod wsl {
#[test]
fn wsl_non_mnt_paths_unchanged() {
let path = PathBuf::from("/home/Dev");
let normalized = normalize_for_wsl_with_flag(path.clone(), true);
let normalized = normalize_for_wsl_with_flag(path.clone(), /*is_wsl*/ true);
assert_eq!(normalized, path);
}
@@ -60,7 +61,7 @@ mod native_workdir {
#[test]
fn windows_verbatim_paths_are_simplified() {
let path = PathBuf::from(r"\\?\D:\c\x\worktrees\2508\swift-base");
let normalized = normalize_for_native_workdir_with_flag(path, true);
let normalized = normalize_for_native_workdir_with_flag(path, /*is_windows*/ true);
assert_eq!(
normalized,
@@ -71,7 +72,8 @@ mod native_workdir {
#[test]
fn non_windows_paths_are_unchanged() {
let path = PathBuf::from(r"\\?\D:\c\x\worktrees\2508\swift-base");
let normalized = normalize_for_native_workdir_with_flag(path.clone(), false);
let normalized =
normalize_for_native_workdir_with_flag(path.clone(), /*is_windows*/ false);
assert_eq!(normalized, path);
}
+24 -12
View File
@@ -426,7 +426,7 @@ async fn pipe_process_round_trips_stdin() -> anyhow::Result<()> {
drop(writer);
session.close_stdin();
let (output, code) = collect_output_until_exit(output_rx, exit_rx, 5_000).await;
let (output, code) = collect_output_until_exit(output_rx, exit_rx, /*timeout_ms*/ 5_000).await;
let text = String::from_utf8_lossy(&output);
assert!(
@@ -535,7 +535,7 @@ async fn pipe_drains_stderr_without_stdout_activity() -> anyhow::Result<()> {
let spawned = spawn_pipe_process(&python, &args, Path::new("."), &env_map, &None).await?;
let (_session, output_rx, exit_rx) = combine_spawned_output(spawned);
let (output, code) = collect_output_until_exit(output_rx, exit_rx, 10_000).await;
let (output, code) = collect_output_until_exit(output_rx, exit_rx, /*timeout_ms*/ 10_000).await;
assert_eq!(code, 0, "expected python to exit cleanly");
assert!(!output.is_empty(), "expected stderr output to be drained");
@@ -644,7 +644,7 @@ async fn pty_terminate_kills_background_children_in_same_process_group() -> anyh
.await?;
let (session, mut output_rx, _exit_rx) = combine_spawned_output(spawned);
let bg_pid = match wait_for_marker_pid(&mut output_rx, marker, 2_000).await {
let bg_pid = match wait_for_marker_pid(&mut output_rx, marker, /*timeout_ms*/ 2_000).await {
Ok(pid) => pid,
Err(err) => {
session.terminate();
@@ -658,7 +658,7 @@ async fn pty_terminate_kills_background_children_in_same_process_group() -> anyh
session.terminate();
let exited = wait_for_process_exit(bg_pid, 3_000).await?;
let exited = wait_for_process_exit(bg_pid, /*timeout_ms*/ 3_000).await?;
if !exited {
let _ = unsafe { libc::kill(bg_pid, libc::SIGKILL) };
}
@@ -708,7 +708,7 @@ async fn pty_spawn_can_preserve_inherited_fds() -> anyhow::Result<()> {
drop(write_end);
let (_session, output_rx, exit_rx) = combine_spawned_output(spawned);
let (_, code) = collect_output_until_exit(output_rx, exit_rx, 2_000).await;
let (_, code) = collect_output_until_exit(output_rx, exit_rx, /*timeout_ms*/ 2_000).await;
assert_eq!(code, 0, "expected preserved-fd PTY child to exit cleanly");
let mut pipe_output = String::new();
@@ -762,14 +762,19 @@ async fn pty_preserving_inherited_fds_keeps_python_repl_running() -> anyhow::Res
let (session, mut output_rx, exit_rx) = combine_spawned_output(spawned);
let writer = session.writer_sender();
let newline = "\n";
let mut output =
wait_for_python_repl_ready_via_probe(&writer, &mut output_rx, 5_000, newline).await?;
let mut output = wait_for_python_repl_ready_via_probe(
&writer,
&mut output_rx,
/*timeout_ms*/ 5_000,
newline,
)
.await?;
let marker = "__codex_preserved_py_pid:";
writer
.send(format!("import os; print('{marker}' + str(os.getpid())){newline}").into_bytes())
.await?;
let python_pid = match wait_for_marker_pid(&mut output_rx, marker, 2_000).await {
let python_pid = match wait_for_marker_pid(&mut output_rx, marker, /*timeout_ms*/ 2_000).await {
Ok(pid) => pid,
Err(err) => {
session.terminate();
@@ -782,7 +787,8 @@ async fn pty_preserving_inherited_fds_keeps_python_repl_running() -> anyhow::Res
);
writer.send(format!("exit(){newline}").into_bytes()).await?;
let (remaining_output, code) = collect_output_until_exit(output_rx, exit_rx, 5_000).await;
let (remaining_output, code) =
collect_output_until_exit(output_rx, exit_rx, /*timeout_ms*/ 5_000).await;
output.extend_from_slice(&remaining_output);
assert_eq!(code, 0, "expected python to exit cleanly");
@@ -871,7 +877,12 @@ async fn pty_spawn_with_inherited_fds_supports_resize() -> anyhow::Result<()> {
let (session, mut output_rx, exit_rx) = combine_spawned_output(spawned);
let writer = session.writer_sender();
let mut output = wait_for_output_contains(&mut output_rx, "start:31 101\r\n", 5_000).await?;
let mut output = wait_for_output_contains(
&mut output_rx,
"start:31 101\r\n",
/*timeout_ms*/ 5_000,
)
.await?;
session.resize(TerminalSize {
rows: 45,
@@ -880,7 +891,8 @@ async fn pty_spawn_with_inherited_fds_supports_resize() -> anyhow::Result<()> {
writer.send(b"go\n".to_vec()).await?;
session.close_stdin();
let (remaining_output, code) = collect_output_until_exit(output_rx, exit_rx, 5_000).await;
let (remaining_output, code) =
collect_output_until_exit(output_rx, exit_rx, /*timeout_ms*/ 5_000).await;
output.extend_from_slice(&remaining_output);
let text = String::from_utf8_lossy(&output);
let normalized = text.replace("\r\n", "\n");
@@ -933,7 +945,7 @@ async fn pipe_spawn_no_stdin_can_preserve_inherited_fds() -> anyhow::Result<()>
drop(write_end);
let (_session, output_rx, exit_rx) = combine_spawned_output(spawned);
let (_, code) = collect_output_until_exit(output_rx, exit_rx, 2_000).await;
let (_, code) = collect_output_until_exit(output_rx, exit_rx, /*timeout_ms*/ 2_000).await;
assert_eq!(code, 0, "expected preserved-fd pipe child to exit cleanly");
let mut pipe_output = String::new();
+16 -16
View File
@@ -77,37 +77,37 @@ mod tests {
#[test]
fn sleep_inhibitor_toggles_without_panicking() {
let mut inhibitor = SleepInhibitor::new(true);
inhibitor.set_turn_running(true);
let mut inhibitor = SleepInhibitor::new(/*enabled*/ true);
inhibitor.set_turn_running(/*turn_running*/ true);
assert!(inhibitor.is_turn_running());
inhibitor.set_turn_running(false);
inhibitor.set_turn_running(/*turn_running*/ false);
assert!(!inhibitor.is_turn_running());
}
#[test]
fn sleep_inhibitor_disabled_does_not_panic() {
let mut inhibitor = SleepInhibitor::new(false);
inhibitor.set_turn_running(true);
let mut inhibitor = SleepInhibitor::new(/*enabled*/ false);
inhibitor.set_turn_running(/*turn_running*/ true);
assert!(inhibitor.is_turn_running());
inhibitor.set_turn_running(false);
inhibitor.set_turn_running(/*turn_running*/ false);
assert!(!inhibitor.is_turn_running());
}
#[test]
fn sleep_inhibitor_multiple_true_calls_are_idempotent() {
let mut inhibitor = SleepInhibitor::new(true);
inhibitor.set_turn_running(true);
inhibitor.set_turn_running(true);
inhibitor.set_turn_running(true);
inhibitor.set_turn_running(false);
let mut inhibitor = SleepInhibitor::new(/*enabled*/ true);
inhibitor.set_turn_running(/*turn_running*/ true);
inhibitor.set_turn_running(/*turn_running*/ true);
inhibitor.set_turn_running(/*turn_running*/ true);
inhibitor.set_turn_running(/*turn_running*/ false);
}
#[test]
fn sleep_inhibitor_can_toggle_multiple_times() {
let mut inhibitor = SleepInhibitor::new(true);
inhibitor.set_turn_running(true);
inhibitor.set_turn_running(false);
inhibitor.set_turn_running(true);
inhibitor.set_turn_running(false);
let mut inhibitor = SleepInhibitor::new(/*enabled*/ true);
inhibitor.set_turn_running(/*turn_running*/ true);
inhibitor.set_turn_running(/*turn_running*/ false);
inhibitor.set_turn_running(/*turn_running*/ true);
inhibitor.set_turn_running(/*turn_running*/ false);
}
}
@@ -80,7 +80,7 @@ mod tests {
#[test]
fn parses_citations_across_seed_and_delta_boundaries() {
let mut parser = AssistantTextStreamParser::new(false);
let mut parser = AssistantTextStreamParser::new(/*plan_mode*/ false);
let seeded = parser.push_str("hello <oai-mem-citation>doc");
let parsed = parser.push_str("1</oai-mem-citation> world");
@@ -96,7 +96,7 @@ mod tests {
#[test]
fn parses_plan_segments_after_citation_stripping() {
let mut parser = AssistantTextStreamParser::new(true);
let mut parser = AssistantTextStreamParser::new(/*plan_mode*/ true);
let seeded = parser.push_str("Intro\n<proposed");
let parsed = parser.push_str("_plan>\n- step <oai-mem-citation>doc</oai-mem-citation>\n");
+59 -13
View File
@@ -5,37 +5,83 @@ use pretty_assertions::assert_eq;
#[test]
fn split_string_works() {
assert_eq!(split_string("hello world", 5, 5), (1, "hello", "world"));
assert_eq!(split_string("abc", 0, 0), (3, "", ""));
assert_eq!(
split_string(
"hello world",
/*beginning_bytes*/ 5,
/*end_bytes*/ 5
),
(1, "hello", "world")
);
assert_eq!(
split_string("abc", /*beginning_bytes*/ 0, /*end_bytes*/ 0),
(3, "", "")
);
}
#[test]
fn split_string_handles_empty_string() {
assert_eq!(split_string("", 4, 4), (0, "", ""));
assert_eq!(
split_string("", /*beginning_bytes*/ 4, /*end_bytes*/ 4),
(0, "", "")
);
}
#[test]
fn split_string_only_keeps_prefix_when_tail_budget_is_zero() {
assert_eq!(split_string("abcdef", 3, 0), (3, "abc", ""));
assert_eq!(
split_string("abcdef", /*beginning_bytes*/ 3, /*end_bytes*/ 0),
(3, "abc", "")
);
}
#[test]
fn split_string_only_keeps_suffix_when_prefix_budget_is_zero() {
assert_eq!(split_string("abcdef", 0, 3), (3, "", "def"));
assert_eq!(
split_string("abcdef", /*beginning_bytes*/ 0, /*end_bytes*/ 3),
(3, "", "def")
);
}
#[test]
fn split_string_handles_overlapping_budgets_without_removal() {
assert_eq!(split_string("abcdef", 4, 4), (0, "abcd", "ef"));
assert_eq!(
split_string("abcdef", /*beginning_bytes*/ 4, /*end_bytes*/ 4),
(0, "abcd", "ef")
);
}
#[test]
fn split_string_respects_utf8_boundaries() {
assert_eq!(split_string("😀abc😀", 5, 5), (1, "😀a", "c😀"));
assert_eq!(
split_string("😀abc😀", /*beginning_bytes*/ 5, /*end_bytes*/ 5),
(1, "😀a", "c😀")
);
assert_eq!(split_string("😀😀😀😀😀", 1, 1), (5, "", ""));
assert_eq!(split_string("😀😀😀😀😀", 7, 7), (3, "😀", "😀"));
assert_eq!(split_string("😀😀😀😀😀", 8, 8), (1, "😀😀", "😀😀"));
assert_eq!(
split_string(
"😀😀😀😀😀",
/*beginning_bytes*/ 1,
/*end_bytes*/ 1
),
(5, "", "")
);
assert_eq!(
split_string(
"😀😀😀😀😀",
/*beginning_bytes*/ 7,
/*end_bytes*/ 7
),
(3, "😀", "😀")
);
assert_eq!(
split_string(
"😀😀😀😀😀",
/*beginning_bytes*/ 8,
/*end_bytes*/ 8
),
(1, "😀😀", "😀😀")
);
}
#[test]
@@ -50,7 +96,7 @@ fn truncate_with_token_budget_returns_original_when_under_limit() {
#[test]
fn truncate_with_token_budget_reports_truncation_at_zero_limit() {
let s = "abcdef";
let (out, original) = truncate_middle_with_token_budget(s, 0);
let (out, original) = truncate_middle_with_token_budget(s, /*max_tokens*/ 0);
assert_eq!(out, "…2 tokens truncated…");
assert_eq!(original, Some(2));
}
@@ -58,7 +104,7 @@ fn truncate_with_token_budget_reports_truncation_at_zero_limit() {
#[test]
fn truncate_middle_tokens_handles_utf8_content() {
let s = "😀😀😀😀😀😀😀😀😀😀\nsecond line with text\n";
let (out, tokens) = truncate_middle_with_token_budget(s, 8);
let (out, tokens) = truncate_middle_with_token_budget(s, /*max_tokens*/ 8);
assert_eq!(out, "😀😀😀😀…8 tokens truncated… line with text\n");
assert_eq!(tokens, Some(16));
}
@@ -66,6 +112,6 @@ fn truncate_middle_tokens_handles_utf8_content() {
#[test]
fn truncate_middle_bytes_handles_utf8_content() {
let s = "😀😀😀😀😀😀😀😀😀😀\nsecond line with text\n";
let out = truncate_middle_chars(s, 20);
let out = truncate_middle_chars(s, /*max_bytes*/ 20);
assert_eq!(out, "😀😀…21 chars truncated…with text\n");
}