From 2caeaf511ed02832e3c9ba450311ebb409ff9450 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Tue, 8 Apr 2025 17:38:33 +0200 Subject: [PATCH] fuzz: Run cargo clippy Unfortunately, cargo clippy fails when testing fuzz_seq_parse_number: ``` error[E0603]: module `number` is private --> fuzz_targets/fuzz_seq_parse_number.rs:9:13 | 9 | use uu_seq::number::PreciseNumber; | ^^^^^^ private module | note: the module `number` is defined here --> /home/drinkcat/dev/coreutils/coreutils/src/uu/seq/src/seq.rs:24:1 | 24 | mod number; | ^^^^^^^^^^ ``` But we can still fix the rest... --- fuzz/fuzz_targets/fuzz_common/mod.rs | 4 ++++ fuzz/fuzz_targets/fuzz_common/pretty_print.rs | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/fuzz/fuzz_targets/fuzz_common/mod.rs b/fuzz/fuzz_targets/fuzz_common/mod.rs index 79abe4645..04910635e 100644 --- a/fuzz/fuzz_targets/fuzz_common/mod.rs +++ b/fuzz/fuzz_targets/fuzz_common/mod.rs @@ -132,6 +132,8 @@ where let (uumain_exit_status, captured_stdout, captured_stderr) = thread::scope(|s| { let out = s.spawn(|| read_from_fd(pipe_stdout_fds[0])); let err = s.spawn(|| read_from_fd(pipe_stderr_fds[0])); + #[allow(clippy::unnecessary_to_owned)] + // TODO: clippy wants us to use args.iter().cloned() ? let status = uumain_function(args.to_owned().into_iter()); // Reset the exit code global variable in case we run another test after this one // See https://github.com/uutils/coreutils/issues/5777 @@ -409,6 +411,7 @@ pub fn generate_random_string(max_length: usize) -> String { result } +#[allow(dead_code)] pub fn generate_random_file() -> Result { let mut rng = rand::rng(); let file_name: String = (0..10) @@ -429,6 +432,7 @@ pub fn generate_random_file() -> Result { Ok(file_path.to_str().unwrap().to_string()) } +#[allow(dead_code)] pub fn replace_fuzz_binary_name(cmd: &str, result: &mut CommandResult) { let fuzz_bin_name = format!("fuzz/target/x86_64-unknown-linux-gnu/release/fuzz_{cmd}"); diff --git a/fuzz/fuzz_targets/fuzz_common/pretty_print.rs b/fuzz/fuzz_targets/fuzz_common/pretty_print.rs index 373094ad4..a0e322429 100644 --- a/fuzz/fuzz_targets/fuzz_common/pretty_print.rs +++ b/fuzz/fuzz_targets/fuzz_common/pretty_print.rs @@ -16,6 +16,7 @@ pub fn print_subsection(s: S) { println!("{}", style(format!("--- {}", s)).bright()); } +#[allow(dead_code)] pub fn print_test_begin(msg: S) { println!( "{} {} {}", @@ -50,7 +51,7 @@ pub fn print_with_style(msg: S, style: Style) { println!("{}", style.apply_to(msg)); } -pub fn print_diff<'a, 'b>(got: &'a str, expected: &'b str) { +pub fn print_diff(got: &str, expected: &str) { let diff = TextDiff::from_lines(got, expected); print_subsection("START diff");