mirror of
https://github.com/uutils/coreutils
synced 2024-12-14 15:22:38 +00:00
Merge pull request #4759 from sylvestre/clippy4
fix some clippy warnings in tests
This commit is contained in:
commit
98fa941250
6 changed files with 12 additions and 11 deletions
|
@ -1621,13 +1621,13 @@ fn test_cp_one_file_system() {
|
||||||
use walkdir::WalkDir;
|
use walkdir::WalkDir;
|
||||||
|
|
||||||
let scene = TestScenario::new(util_name!());
|
let scene = TestScenario::new(util_name!());
|
||||||
|
let at = &scene.fixtures;
|
||||||
|
|
||||||
// Test must be run as root (or with `sudo -E`)
|
// Test must be run as root (or with `sudo -E`)
|
||||||
if scene.cmd("whoami").run().stdout_str() != "root\n" {
|
if scene.cmd("whoami").run().stdout_str() != "root\n" {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let at = scene.fixtures.clone();
|
|
||||||
let at_src = AtPath::new(&at.plus(TEST_MOUNT_COPY_FROM_FOLDER));
|
let at_src = AtPath::new(&at.plus(TEST_MOUNT_COPY_FROM_FOLDER));
|
||||||
let at_dst = AtPath::new(&at.plus(TEST_COPY_TO_FOLDER_NEW));
|
let at_dst = AtPath::new(&at.plus(TEST_COPY_TO_FOLDER_NEW));
|
||||||
|
|
||||||
|
|
|
@ -1239,7 +1239,7 @@ fn test_ls_long_total_size() {
|
||||||
("long_si", "total 8.2k"),
|
("long_si", "total 8.2k"),
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.copied()
|
||||||
.collect()
|
.collect()
|
||||||
} else {
|
} else {
|
||||||
[
|
[
|
||||||
|
@ -1248,7 +1248,7 @@ fn test_ls_long_total_size() {
|
||||||
("long_si", "total 2"),
|
("long_si", "total 2"),
|
||||||
]
|
]
|
||||||
.iter()
|
.iter()
|
||||||
.cloned()
|
.copied()
|
||||||
.collect()
|
.collect()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn test_deleted_dir() {
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
let ts = TestScenario::new(util_name!());
|
let ts = TestScenario::new(util_name!());
|
||||||
let at = ts.fixtures.clone();
|
let at = ts.fixtures;
|
||||||
let output = Command::new("sh")
|
let output = Command::new("sh")
|
||||||
.arg("-c")
|
.arg("-c")
|
||||||
.arg(format!(
|
.arg(format!(
|
||||||
|
|
|
@ -118,9 +118,10 @@ mod linux_only {
|
||||||
use std::os::unix::io::FromRawFd;
|
use std::os::unix::io::FromRawFd;
|
||||||
|
|
||||||
let mut fds: [c_int; 2] = [0, 0];
|
let mut fds: [c_int; 2] = [0, 0];
|
||||||
if unsafe { libc::pipe(&mut fds as *mut c_int) } != 0 {
|
assert!(
|
||||||
panic!("Failed to create pipe");
|
(unsafe { libc::pipe(&mut fds as *mut c_int) } == 0),
|
||||||
}
|
"Failed to create pipe"
|
||||||
|
);
|
||||||
|
|
||||||
// Drop the read end of the pipe
|
// Drop the read end of the pipe
|
||||||
let _ = unsafe { File::from_raw_fd(fds[0]) };
|
let _ = unsafe { File::from_raw_fd(fds[0]) };
|
||||||
|
|
|
@ -6,12 +6,12 @@ use std::os::unix::process::ExitStatusExt;
|
||||||
use crate::common::util::TestScenario;
|
use crate::common::util::TestScenario;
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn check_termination(result: &ExitStatus) {
|
fn check_termination(result: ExitStatus) {
|
||||||
assert_eq!(result.signal(), Some(libc::SIGPIPE));
|
assert_eq!(result.signal(), Some(libc::SIGPIPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(unix))]
|
#[cfg(not(unix))]
|
||||||
fn check_termination(result: &ExitStatus) {
|
fn check_termination(result: ExitStatus) {
|
||||||
assert!(result.success(), "yes did not exit successfully");
|
assert!(result.success(), "yes did not exit successfully");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ fn run(args: &[&str], expected: &[u8]) {
|
||||||
child.close_stdout();
|
child.close_stdout();
|
||||||
|
|
||||||
#[allow(deprecated)]
|
#[allow(deprecated)]
|
||||||
check_termination(&child.wait_with_output().unwrap().status);
|
check_termination(child.wait_with_output().unwrap().status);
|
||||||
assert_eq!(buf.as_slice(), expected);
|
assert_eq!(buf.as_slice(), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2016,7 +2016,7 @@ impl UChild {
|
||||||
|
|
||||||
/// Read, consume and return the output as [`String`] from [`Child`]'s stdout.
|
/// Read, consume and return the output as [`String`] from [`Child`]'s stdout.
|
||||||
///
|
///
|
||||||
/// See also [`UChild::stdout_bytes] for side effects.
|
/// See also [`UChild::stdout_bytes`] for side effects.
|
||||||
pub fn stdout(&mut self) -> String {
|
pub fn stdout(&mut self) -> String {
|
||||||
String::from_utf8(self.stdout_bytes()).unwrap()
|
String::from_utf8(self.stdout_bytes()).unwrap()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue