1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 13:37:48 +00:00

Merge pull request #2360 from rivy/fix+rf

build and *lots* of clippy fixes
This commit is contained in:
Sylvestre Ledru 2021-06-08 22:06:11 +02:00 committed by GitHub
commit 4471335609
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
71 changed files with 265 additions and 271 deletions

View file

@ -438,7 +438,7 @@ fn test_domain_socket() {
let child = new_ucmd!().args(&[socket_path]).run_no_wait();
barrier.wait();
let stdout = &child.wait_with_output().unwrap().stdout;
let output = String::from_utf8_lossy(&stdout);
let output = String::from_utf8_lossy(stdout);
assert_eq!("a\tb", output);
thread.join().unwrap();

View file

@ -618,7 +618,7 @@ fn test_cp_deref() {
// Check the content of the destination file that was copied.
assert_eq!(at.read(TEST_COPY_TO_FOLDER_FILE), "Hello, World!\n");
let path_to_check = path_to_new_symlink.to_str().unwrap();
assert_eq!(at.read(&path_to_check), "Hello, World!\n");
assert_eq!(at.read(path_to_check), "Hello, World!\n");
}
#[test]
fn test_cp_no_deref() {
@ -655,7 +655,7 @@ fn test_cp_no_deref() {
// Check the content of the destination file that was copied.
assert_eq!(at.read(TEST_COPY_TO_FOLDER_FILE), "Hello, World!\n");
let path_to_check = path_to_new_symlink.to_str().unwrap();
assert_eq!(at.read(&path_to_check), "Hello, World!\n");
assert_eq!(at.read(path_to_check), "Hello, World!\n");
}
#[test]
@ -823,7 +823,7 @@ fn test_cp_deref_folder_to_folder() {
// Check the content of the symlink
let path_to_check = path_to_new_symlink.to_str().unwrap();
assert_eq!(at.read(&path_to_check), "Hello, World!\n");
assert_eq!(at.read(path_to_check), "Hello, World!\n");
}
#[test]
@ -923,7 +923,7 @@ fn test_cp_no_deref_folder_to_folder() {
// Check the content of the symlink
let path_to_check = path_to_new_symlink.to_str().unwrap();
assert_eq!(at.read(&path_to_check), "Hello, World!\n");
assert_eq!(at.read(path_to_check), "Hello, World!\n");
}
#[test]

View file

@ -187,11 +187,10 @@ fn test_change_directory() {
.arg(&temporary_path)
.succeeds()
.stdout_move_str();
assert_eq!(
out.lines()
.any(|line| line.ends_with(temporary_path.file_name().unwrap().to_str().unwrap())),
false
);
assert!(!out
.lines()
.any(|line| line.ends_with(temporary_path.file_name().unwrap().to_str().unwrap())));
}
#[test]

View file

@ -398,7 +398,7 @@ fn test_ls_long_formats() {
.arg("--author")
.arg("test-long-formats")
.succeeds();
assert!(re_three.is_match(&result.stdout_str()));
assert!(re_three.is_match(result.stdout_str()));
#[cfg(unix)]
{
@ -701,20 +701,20 @@ fn test_ls_styles() {
.arg("-l")
.arg("--time-style=full-iso")
.succeeds();
assert!(re_full.is_match(&result.stdout_str()));
assert!(re_full.is_match(result.stdout_str()));
//long-iso
let result = scene
.ucmd()
.arg("-l")
.arg("--time-style=long-iso")
.succeeds();
assert!(re_long.is_match(&result.stdout_str()));
assert!(re_long.is_match(result.stdout_str()));
//iso
let result = scene.ucmd().arg("-l").arg("--time-style=iso").succeeds();
assert!(re_iso.is_match(&result.stdout_str()));
assert!(re_iso.is_match(result.stdout_str()));
//locale
let result = scene.ucmd().arg("-l").arg("--time-style=locale").succeeds();
assert!(re_locale.is_match(&result.stdout_str()));
assert!(re_locale.is_match(result.stdout_str()));
//Overwrite options tests
let result = scene
@ -723,19 +723,19 @@ fn test_ls_styles() {
.arg("--time-style=long-iso")
.arg("--time-style=iso")
.succeeds();
assert!(re_iso.is_match(&result.stdout_str()));
assert!(re_iso.is_match(result.stdout_str()));
let result = scene
.ucmd()
.arg("--time-style=iso")
.arg("--full-time")
.succeeds();
assert!(re_full.is_match(&result.stdout_str()));
assert!(re_full.is_match(result.stdout_str()));
let result = scene
.ucmd()
.arg("--full-time")
.arg("--time-style=iso")
.succeeds();
assert!(re_iso.is_match(&result.stdout_str()));
assert!(re_iso.is_match(result.stdout_str()));
let result = scene
.ucmd()
@ -743,7 +743,7 @@ fn test_ls_styles() {
.arg("--time-style=iso")
.arg("--full-time")
.succeeds();
assert!(re_full.is_match(&result.stdout_str()));
assert!(re_full.is_match(result.stdout_str()));
let result = scene
.ucmd()
@ -751,7 +751,7 @@ fn test_ls_styles() {
.arg("-x")
.arg("-l")
.succeeds();
assert!(re_full.is_match(&result.stdout_str()));
assert!(re_full.is_match(result.stdout_str()));
at.touch("test2");
let result = scene.ucmd().arg("--full-time").arg("-x").succeeds();
@ -1143,7 +1143,7 @@ fn test_ls_indicator_style() {
for opt in options {
scene
.ucmd()
.arg(format!("{}", opt))
.arg(opt.to_string())
.succeeds()
.stdout_contains(&"/");
}

View file

@ -38,7 +38,7 @@ fn test_posix_mode() {
// fail on long path
new_ucmd!()
.args(&["-p", &"dir".repeat(libc::PATH_MAX as usize + 1).as_str()])
.args(&["-p", "dir".repeat(libc::PATH_MAX as usize + 1).as_str()])
.fails()
.no_stdout();
@ -46,7 +46,7 @@ fn test_posix_mode() {
new_ucmd!()
.args(&[
"-p",
&format!("dir/{}", "file".repeat(libc::FILENAME_MAX as usize + 1)).as_str(),
format!("dir/{}", "file".repeat(libc::FILENAME_MAX as usize + 1)).as_str(),
])
.fails()
.no_stdout();
@ -76,7 +76,7 @@ fn test_posix_special() {
// fail on long path
new_ucmd!()
.args(&["-P", &"dir".repeat(libc::PATH_MAX as usize + 1).as_str()])
.args(&["-P", "dir".repeat(libc::PATH_MAX as usize + 1).as_str()])
.fails()
.no_stdout();
@ -84,7 +84,7 @@ fn test_posix_special() {
new_ucmd!()
.args(&[
"-P",
&format!("dir/{}", "file".repeat(libc::FILENAME_MAX as usize + 1)).as_str(),
format!("dir/{}", "file".repeat(libc::FILENAME_MAX as usize + 1)).as_str(),
])
.fails()
.no_stdout();
@ -117,7 +117,7 @@ fn test_posix_all() {
.args(&[
"-p",
"-P",
&"dir".repeat(libc::PATH_MAX as usize + 1).as_str(),
"dir".repeat(libc::PATH_MAX as usize + 1).as_str(),
])
.fails()
.no_stdout();
@ -127,7 +127,7 @@ fn test_posix_all() {
.args(&[
"-p",
"-P",
&format!("dir/{}", "file".repeat(libc::FILENAME_MAX as usize + 1)).as_str(),
format!("dir/{}", "file".repeat(libc::FILENAME_MAX as usize + 1)).as_str(),
])
.fails()
.no_stdout();

View file

@ -102,6 +102,8 @@ fn expected_result(args: &[&str]) -> String {
#[cfg(target_vendor = "apple")]
let util_name = format!("g{}", util_name!());
// note: clippy::needless_borrow *false positive*
#[allow(clippy::needless_borrow)]
TestScenario::new(&util_name)
.cmd_keepenv(util_name)
.env("LANGUAGE", "C")

View file

@ -844,12 +844,7 @@ fn test_compress_fail() {
#[test]
fn test_merge_batches() {
new_ucmd!()
.args(&[
"ext_sort.txt",
"-n",
"-S",
"150B",
])
.args(&["ext_sort.txt", "-n", "-S", "150B"])
.succeeds()
.stdout_only_fixture("ext_sort.expected");
}

View file

@ -313,6 +313,8 @@ fn expected_result(args: &[&str]) -> String {
#[cfg(target_vendor = "apple")]
let util_name = format!("g{}", util_name!());
// note: clippy::needless_borrow *false positive*
#[allow(clippy::needless_borrow)]
TestScenario::new(&util_name)
.cmd_keepenv(util_name)
.env("LANGUAGE", "C")

View file

@ -13,6 +13,8 @@ fn test_users_check_name() {
#[cfg(target_vendor = "apple")]
let util_name = format!("g{}", util_name!());
// note: clippy::needless_borrow *false positive*
#[allow(clippy::needless_borrow)]
let expected = TestScenario::new(&util_name)
.cmd_keepenv(util_name)
.env("LANGUAGE", "C")

View file

@ -238,6 +238,8 @@ fn expected_result(args: &[&str]) -> String {
#[cfg(target_vendor = "apple")]
let util_name = format!("g{}", util_name!());
// note: clippy::needless_borrow *false positive*
#[allow(clippy::needless_borrow)]
TestScenario::new(&util_name)
.cmd_keepenv(util_name)
.env("LANGUAGE", "C")

View file

@ -625,11 +625,20 @@ impl AtPath {
// Source:
// http://stackoverflow.com/questions/31439011/getfinalpathnamebyhandle-without-prepended
let prefix = "\\\\?\\";
// FixME: replace ...
#[allow(clippy::manual_strip)]
if s.starts_with(prefix) {
String::from(&s[prefix.len()..])
} else {
s
}
// ... with ...
// if let Some(stripped) = s.strip_prefix(prefix) {
// String::from(stripped)
// } else {
// s
// }
// ... when using MSRV with stabilized `strip_prefix()`
}
}