From d42b4883e1bbd4c2e74e75bbb61d927548af9ea8 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 18 Mar 2023 14:35:53 +0100 Subject: [PATCH 1/2] Fix some simply clippy warnings With: `cargo +nightly clippy --features unix --allow-dirty --fix -- -W clippy::pedantic` --- tests/common/util.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/common/util.rs b/tests/common/util.rs index 6c7072ff4..dfe39583c 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -2812,7 +2812,7 @@ mod tests { #[should_panic] fn test_cmd_result_stdout_check_when_false_then_panics() { let result = TestScenario::new("echo").ucmd().arg("Hello world").run(); - result.stdout_check(|s| s.is_empty()); + result.stdout_check(<[u8]>::is_empty); } #[cfg(feature = "echo")] @@ -3055,9 +3055,10 @@ mod tests { // check `child.is_alive()` and `child.delay()` is working let mut trials = 10; while child.is_alive() { - if trials <= 0 { - panic!("Assertion failed: child process is still alive.") - } + assert!( + trials > 0, + "Assertion failed: child process is still alive." + ); child.delay(500); trials -= 1; From be6d5bfb9cf13a4cac39a582ad33c95f9daa4be9 Mon Sep 17 00:00:00 2001 From: Sylvestre Ledru Date: Sat, 18 Mar 2023 14:50:43 +0100 Subject: [PATCH 2/2] Fix some redundant closure in test_shurf --- tests/by-util/test_shuf.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/by-util/test_shuf.rs b/tests/by-util/test_shuf.rs index 39a7a640b..23851aacc 100644 --- a/tests/by-util/test_shuf.rs +++ b/tests/by-util/test_shuf.rs @@ -10,7 +10,7 @@ fn test_output_is_random_permutation() { let input_seq = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let input = input_seq .iter() - .map(|x| x.to_string()) + .map(ToString::to_string) .collect::>() .join("\n"); @@ -52,7 +52,7 @@ fn test_echo() { .args( &input_seq .iter() - .map(|x| x.to_string()) + .map(ToString::to_string) .collect::>(), ) .succeeds(); @@ -74,7 +74,7 @@ fn test_head_count() { let input_seq = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let input = input_seq .iter() - .map(|x| x.to_string()) + .map(ToString::to_string) .collect::>() .join("\n"); @@ -105,7 +105,7 @@ fn test_repeat() { let input_seq = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; let input = input_seq .iter() - .map(|x| x.to_string()) + .map(ToString::to_string) .collect::>() .join("\n");