mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-15 11:36:16 +00:00
Fix some clippy warnings
This commit is contained in:
parent
682f488720
commit
7c9f4ba92a
23 changed files with 50 additions and 55 deletions
|
@ -2022,12 +2022,12 @@ fn test_cp_reflink_always_override() {
|
|||
const USERDIR: &str = "dir/";
|
||||
const MOUNTPOINT: &str = "mountpoint/";
|
||||
|
||||
let src1_path: &str = &vec![MOUNTPOINT, USERDIR, "src1"].concat();
|
||||
let src2_path: &str = &vec![MOUNTPOINT, USERDIR, "src2"].concat();
|
||||
let dst_path: &str = &vec![MOUNTPOINT, USERDIR, "dst"].concat();
|
||||
let src1_path: &str = &[MOUNTPOINT, USERDIR, "src1"].concat();
|
||||
let src2_path: &str = &[MOUNTPOINT, USERDIR, "src2"].concat();
|
||||
let dst_path: &str = &[MOUNTPOINT, USERDIR, "dst"].concat();
|
||||
|
||||
scene.fixtures.mkdir(ROOTDIR);
|
||||
scene.fixtures.mkdir(vec![ROOTDIR, USERDIR].concat());
|
||||
scene.fixtures.mkdir([ROOTDIR, USERDIR].concat());
|
||||
|
||||
// Setup:
|
||||
// Because neither `mkfs.btrfs` not btrfs `mount` options allow us to have a mountpoint owned
|
||||
|
|
|
@ -173,7 +173,6 @@ fn test_random() {
|
|||
break;
|
||||
}
|
||||
}
|
||||
let factor = factor;
|
||||
|
||||
match product.checked_mul(factor) {
|
||||
Some(p) => {
|
||||
|
@ -317,7 +316,7 @@ fn run(input_string: &[u8], output_string: &[u8]) {
|
|||
fn test_primes_with_exponents() {
|
||||
let mut input_string = String::new();
|
||||
let mut output_string = String::new();
|
||||
for primes in PRIMES_BY_BITS.iter() {
|
||||
for primes in PRIMES_BY_BITS {
|
||||
for &prime in *primes {
|
||||
input_string.push_str(&(format!("{prime} "))[..]);
|
||||
output_string.push_str(&(format!("{prime}: {prime}\n"))[..]);
|
||||
|
|
|
@ -58,7 +58,7 @@ fn test_link_one_argument() {
|
|||
#[test]
|
||||
fn test_link_three_arguments() {
|
||||
let (_, mut ucmd) = at_and_ucmd!();
|
||||
let arguments = vec![
|
||||
let arguments = [
|
||||
"test_link_argument1",
|
||||
"test_link_argument2",
|
||||
"test_link_argument3",
|
||||
|
|
|
@ -1278,7 +1278,7 @@ fn test_mv_verbose() {
|
|||
|
||||
#[test]
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))] // mkdir does not support -m on windows. Freebsd doesn't return a permission error either.
|
||||
#[cfg(features = "mkdir")]
|
||||
#[cfg(feature = "mkdir")]
|
||||
fn test_mv_permission_error() {
|
||||
let scene = TestScenario::new("mkdir");
|
||||
let folder1 = "bar";
|
||||
|
|
|
@ -478,7 +478,7 @@ fn test_rm_prompts() {
|
|||
// Needed for talking with stdin on platforms where CRLF or LF matters
|
||||
const END_OF_LINE: &str = if cfg!(windows) { "\r\n" } else { "\n" };
|
||||
|
||||
let mut answers = vec![
|
||||
let mut answers = [
|
||||
"rm: descend into directory 'a'?",
|
||||
"rm: remove write-protected regular empty file 'a/empty-no-write'?",
|
||||
"rm: remove symbolic link 'a/slink'?",
|
||||
|
|
|
@ -71,7 +71,7 @@ fn test_echo() {
|
|||
#[test]
|
||||
fn test_head_count() {
|
||||
let repeat_limit = 5;
|
||||
let input_seq = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
let input_seq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
let input = input_seq
|
||||
.iter()
|
||||
.map(ToString::to_string)
|
||||
|
@ -102,7 +102,7 @@ fn test_head_count() {
|
|||
#[test]
|
||||
fn test_repeat() {
|
||||
let repeat_limit = 15000;
|
||||
let input_seq = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
let input_seq = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||
let input = input_seq
|
||||
.iter()
|
||||
.map(ToString::to_string)
|
||||
|
|
|
@ -541,7 +541,7 @@ impl CmdResult {
|
|||
let contents = String::from_utf8(read_scenario_fixture(&self.tmpd, file_rel_path)).unwrap();
|
||||
let possible_values = template_vars.iter().map(|vars| {
|
||||
let mut contents = contents.clone();
|
||||
for kv in vars.iter() {
|
||||
for kv in vars {
|
||||
contents = contents.replace(&kv.0, &kv.1);
|
||||
}
|
||||
contents
|
||||
|
@ -2211,12 +2211,12 @@ impl UChild {
|
|||
let join_handle = thread::spawn(move || {
|
||||
let mut writer = BufWriter::new(stdin);
|
||||
|
||||
match writer.write_all(&content).and_then(|_| writer.flush()) {
|
||||
match writer.write_all(&content).and_then(|()| writer.flush()) {
|
||||
Err(error) if !ignore_stdin_write_error => Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("failed to write to stdin of child: {error}"),
|
||||
)),
|
||||
Ok(_) | Err(_) => Ok(()),
|
||||
Ok(()) | Err(_) => Ok(()),
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -2263,12 +2263,12 @@ impl UChild {
|
|||
pub fn try_write_in<T: Into<Vec<u8>>>(&mut self, data: T) -> io::Result<()> {
|
||||
let stdin = self.raw.stdin.as_mut().unwrap();
|
||||
|
||||
match stdin.write_all(&data.into()).and_then(|_| stdin.flush()) {
|
||||
match stdin.write_all(&data.into()).and_then(|()| stdin.flush()) {
|
||||
Err(error) if !self.ignore_stdin_write_error => Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("failed to write to stdin of child: {error}"),
|
||||
)),
|
||||
Ok(_) | Err(_) => Ok(()),
|
||||
Ok(()) | Err(_) => Ok(()),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2505,11 +2505,11 @@ pub fn expected_result(ts: &TestScenario, args: &[&str]) -> std::result::Result<
|
|||
|
||||
/// This is a convenience wrapper to run a ucmd with root permissions.
|
||||
/// It can be used to test programs when being root is needed
|
||||
/// This runs 'sudo -E --non-interactive target/debug/coreutils util_name args`
|
||||
/// This runs `sudo -E --non-interactive target/debug/coreutils util_name args`
|
||||
/// This is primarily designed to run in an environment where whoami is in $path
|
||||
/// and where non-interactive sudo is possible.
|
||||
/// To check if i) non-interactive sudo is possible and ii) if sudo works, this runs:
|
||||
/// 'sudo -E --non-interactive whoami' first.
|
||||
/// `sudo -E --non-interactive whoami` first.
|
||||
///
|
||||
/// This return an `Err()` if run inside CICD because there's no 'sudo'.
|
||||
///
|
||||
|
@ -3279,7 +3279,7 @@ mod tests {
|
|||
std::assert_eq!(error.to_string(), "kill: Timeout of '0s' reached");
|
||||
}
|
||||
Err(error) => panic!("Assertion failed: Expected error with timeout but was: {error}"),
|
||||
Ok(_) => panic!("Assertion failed: Expected timeout of `try_kill`."),
|
||||
Ok(()) => panic!("Assertion failed: Expected timeout of `try_kill`."),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue