Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix some clippy warnings in tests #4759

Merged
merged 4 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/by-util/test_cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1394,13 +1394,13 @@ fn test_cp_one_file_system() {
use walkdir::WalkDir;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you remove this line? Seems like a useful separator between imports and variable declarations.

let scene = TestScenario::new(util_name!());
sylvestre marked this conversation as resolved.
Show resolved Hide resolved
let at = &scene.fixtures;

// Test must be run as root (or with `sudo -E`)
if scene.cmd("whoami").run().stdout_str() != "root\n" {
return;
}

let at = scene.fixtures.clone();
let at_src = AtPath::new(&at.plus(TEST_MOUNT_COPY_FROM_FOLDER));
let at_dst = AtPath::new(&at.plus(TEST_COPY_TO_FOLDER_NEW));

Expand Down
4 changes: 2 additions & 2 deletions tests/by-util/test_ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ fn test_ls_long_total_size() {
("long_si", "total 8.2k"),
]
.iter()
.cloned()
.copied()
.collect()
} else {
[
Expand All @@ -1248,7 +1248,7 @@ fn test_ls_long_total_size() {
("long_si", "total 2"),
]
.iter()
.cloned()
.copied()
.collect()
};

Expand Down
2 changes: 1 addition & 1 deletion tests/by-util/test_pwd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn test_deleted_dir() {
use std::process::Command;

let ts = TestScenario::new(util_name!());
let at = ts.fixtures.clone();
let at = ts.fixtures;
let output = Command::new("sh")
.arg("-c")
.arg(format!(
Expand Down
7 changes: 4 additions & 3 deletions tests/by-util/test_tee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ mod linux_only {
use std::os::unix::io::FromRawFd;

let mut fds: [c_int; 2] = [0, 0];
if unsafe { libc::pipe(&mut fds as *mut c_int) } != 0 {
panic!("Failed to create pipe");
}
assert!(
(unsafe { libc::pipe(&mut fds as *mut c_int) } == 0),
"Failed to create pipe"
);

// Drop the read end of the pipe
let _ = unsafe { File::from_raw_fd(fds[0]) };
Expand Down
6 changes: 3 additions & 3 deletions tests/by-util/test_yes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ use std::os::unix::process::ExitStatusExt;
use crate::common::util::TestScenario;

#[cfg(unix)]
fn check_termination(result: &ExitStatus) {
fn check_termination(result: ExitStatus) {
assert_eq!(result.signal(), Some(libc::SIGPIPE));
}

#[cfg(not(unix))]
fn check_termination(result: &ExitStatus) {
fn check_termination(result: ExitStatus) {
assert!(result.success(), "yes did not exit successfully");
}

Expand All @@ -23,7 +23,7 @@ fn run(args: &[&str], expected: &[u8]) {
child.close_stdout();

#[allow(deprecated)]
check_termination(&child.wait_with_output().unwrap().status);
check_termination(child.wait_with_output().unwrap().status);
assert_eq!(buf.as_slice(), expected);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/common/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2016,7 +2016,7 @@ impl UChild {

/// 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 {
String::from_utf8(self.stdout_bytes()).unwrap()
}
Expand Down