1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-08-01 21:47:46 +00:00

Fix clippy::uninlined_format_args .

This commit is contained in:
David Campbell 2024-09-19 17:56:27 -04:00
parent 5d986bfb4c
commit 353eb53367
No known key found for this signature in database
GPG key ID: C2E99A0CF863A603
39 changed files with 127 additions and 169 deletions

View file

@ -341,7 +341,7 @@ fn test_cp_arg_update_none_fail() {
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg("--update=none-fail")
.fails()
.stderr_contains(format!("not replacing '{}'", TEST_HOW_ARE_YOU_SOURCE));
.stderr_contains(format!("not replacing '{TEST_HOW_ARE_YOU_SOURCE}'"));
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "How are you?\n");
}
@ -3897,7 +3897,7 @@ fn test_acl_preserve() {
return;
}
Err(e) => {
println!("test skipped: setfacl failed with {}", e);
println!("test skipped: setfacl failed with {e}");
return;
}
}
@ -5581,7 +5581,7 @@ fn test_dir_perm_race_with_preserve_mode_and_ownership() {
let child = scene
.ucmd()
.args(&[
format!("--preserve={}", attr).as_str(),
format!("--preserve={attr}").as_str(),
"-R",
"--copy-contents",
"--parents",
@ -5600,12 +5600,12 @@ fn test_dir_perm_race_with_preserve_mode_and_ownership() {
start_time.elapsed() < timeout,
"timed out: cp took too long to create destination directory"
);
if at.dir_exists(&format!("{}/{}", DEST_DIR, SRC_DIR)) {
if at.dir_exists(&format!("{DEST_DIR}/{SRC_DIR}")) {
break;
}
std::thread::sleep(Duration::from_millis(100));
}
let mode = at.metadata(&format!("{}/{}", DEST_DIR, SRC_DIR)).mode();
let mode = at.metadata(&format!("{DEST_DIR}/{SRC_DIR}")).mode();
#[allow(clippy::unnecessary_cast, clippy::cast_lossless)]
let mask = if attr == "mode" {
libc::S_IWGRP | libc::S_IWOTH
@ -5615,8 +5615,7 @@ fn test_dir_perm_race_with_preserve_mode_and_ownership() {
assert_eq!(
(mode & mask),
0,
"unwanted permissions are present - {}",
attr
"unwanted permissions are present - {attr}"
);
at.write(FIFO, "done");
child.wait().unwrap().succeeded();
@ -5673,18 +5672,15 @@ fn test_preserve_attrs_overriding_2() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.mkdir(FOLDER);
at.make_file(&format!("{}/{}", FOLDER, FILE1));
at.set_mode(&format!("{}/{}", FOLDER, FILE1), 0o775);
at.hard_link(
&format!("{}/{}", FOLDER, FILE1),
&format!("{}/{}", FOLDER, FILE2),
);
at.make_file(&format!("{FOLDER}/{FILE1}"));
at.set_mode(&format!("{FOLDER}/{FILE1}"), 0o775);
at.hard_link(&format!("{FOLDER}/{FILE1}"), &format!("{FOLDER}/{FILE2}"));
args.append(&mut vec![FOLDER, DEST]);
let src_file1_metadata = at.metadata(&format!("{}/{}", FOLDER, FILE1));
let src_file1_metadata = at.metadata(&format!("{FOLDER}/{FILE1}"));
scene.ucmd().args(&args).succeeds();
at.dir_exists(DEST);
let dest_file1_metadata = at.metadata(&format!("{}/{}", DEST, FILE1));
let dest_file2_metadata = at.metadata(&format!("{}/{}", DEST, FILE2));
let dest_file1_metadata = at.metadata(&format!("{DEST}/{FILE1}"));
let dest_file2_metadata = at.metadata(&format!("{DEST}/{FILE2}"));
assert_eq!(
src_file1_metadata.modified().unwrap(),
dest_file1_metadata.modified().unwrap()

View file

@ -1649,7 +1649,7 @@ fn test_reading_partial_blocks_from_fifo() {
// until the writer process starts).
let mut reader_command = Command::new(TESTS_BINARY);
let child = reader_command
.args(["dd", "ibs=3", "obs=3", &format!("if={}", fifoname)])
.args(["dd", "ibs=3", "obs=3", &format!("if={fifoname}")])
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
@ -1661,7 +1661,7 @@ fn test_reading_partial_blocks_from_fifo() {
writer_command
.args([
"-c",
&format!("(printf \"ab\"; sleep 0.1; printf \"cd\") > {}", fifoname),
&format!("(printf \"ab\"; sleep 0.1; printf \"cd\") > {fifoname}"),
])
.spawn()
.unwrap();
@ -1692,7 +1692,7 @@ fn test_reading_partial_blocks_from_fifo_unbuffered() {
// `bs=N` takes precedence over `ibs=N` and `obs=N`.
let mut reader_command = Command::new(TESTS_BINARY);
let child = reader_command
.args(["dd", "bs=3", "ibs=1", "obs=1", &format!("if={}", fifoname)])
.args(["dd", "bs=3", "ibs=1", "obs=1", &format!("if={fifoname}")])
.stdout(Stdio::piped())
.stderr(Stdio::piped())
.spawn()
@ -1704,7 +1704,7 @@ fn test_reading_partial_blocks_from_fifo_unbuffered() {
writer_command
.args([
"-c",
&format!("(printf \"ab\"; sleep 0.1; printf \"cd\") > {}", fifoname),
&format!("(printf \"ab\"; sleep 0.1; printf \"cd\") > {fifoname}"),
])
.spawn()
.unwrap();
@ -1769,10 +1769,10 @@ fn test_stdin_stdout_not_rewound_even_when_connected_to_seekable_file() {
.succeeds();
let err_file_content = std::fs::read_to_string(at.plus_as_string("err")).unwrap();
println!("stderr:\n{}", err_file_content);
println!("stderr:\n{err_file_content}");
let out_file_content = std::fs::read_to_string(at.plus_as_string("out")).unwrap();
println!("stdout:\n{}", out_file_content);
println!("stdout:\n{out_file_content}");
assert_eq!(out_file_content, "bde");
}

View file

@ -935,7 +935,7 @@ mod tests_split_iterator {
// minimal amount of quoting in typical cases.
match escape_style(s) {
EscapeStyle::None => s.into(),
EscapeStyle::SingleQuoted => format!("'{}'", s).into(),
EscapeStyle::SingleQuoted => format!("'{s}'").into(),
EscapeStyle::Mixed => {
let mut quoted = String::new();
quoted.push('\'');
@ -1015,17 +1015,13 @@ mod tests_split_iterator {
match split(input) {
Err(actual) => {
panic!(
"[{i}] calling split({:?}):\nexpected: Ok({:?})\n actual: Err({:?})\n",
input, expected, actual
"[{i}] calling split({input:?}):\nexpected: Ok({expected:?})\n actual: Err({actual:?})\n"
);
}
Ok(actual) => {
assert!(
expected == actual.as_slice(),
"[{i}] After split({:?}).unwrap()\nexpected: {:?}\n actual: {:?}\n",
input,
expected,
actual
"[{i}] After split({input:?}).unwrap()\nexpected: {expected:?}\n actual: {actual:?}\n"
);
}
}

View file

@ -174,7 +174,7 @@ fn get_filesystem_type(scene: &TestScenario, path: &Path) -> String {
let regex = Regex::new(regex_str).unwrap();
let m = regex.captures(&stdout_str).unwrap();
let fstype = m["fstype"].to_owned();
println!("detected fstype: {}", fstype);
println!("detected fstype: {fstype}");
fstype
}
@ -4120,7 +4120,7 @@ fn test_ls_dired_recursive_multiple() {
let result = cmd.succeeds();
let output = result.stdout_str().to_string();
println!("Output:\n{}", output);
println!("Output:\n{output}");
let dired_line = output
.lines()
@ -4143,7 +4143,7 @@ fn test_ls_dired_recursive_multiple() {
.unwrap()
.trim()
.to_string();
println!("Extracted filename: {}", filename);
println!("Extracted filename: {filename}");
filename
})
.collect();
@ -4229,8 +4229,8 @@ fn test_ls_dired_complex() {
.skip(1)
.map(|s| s.parse().unwrap())
.collect();
println!("{:?}", positions);
println!("Parsed byte positions: {:?}", positions);
println!("{positions:?}");
println!("Parsed byte positions: {positions:?}");
assert_eq!(positions.len() % 2, 0); // Ensure there's an even number of positions
let filenames: Vec<String> = positions
@ -4242,12 +4242,12 @@ fn test_ls_dired_complex() {
.unwrap()
.trim()
.to_string();
println!("Extracted filename: {}", filename);
println!("Extracted filename: {filename}");
filename
})
.collect();
println!("Extracted filenames: {:?}", filenames);
println!("Extracted filenames: {filenames:?}");
assert_eq!(filenames, vec!["a1", "a22", "a333", "a4444", "d"]);
}
@ -4269,7 +4269,7 @@ fn test_ls_subdired_complex() {
let result = cmd.succeeds();
let output = result.stdout_str().to_string();
println!("Output:\n{}", output);
println!("Output:\n{output}");
let dired_line = output
.lines()
@ -4280,7 +4280,7 @@ fn test_ls_subdired_complex() {
.skip(1)
.map(|s| s.parse().unwrap())
.collect();
println!("Parsed byte positions: {:?}", positions);
println!("Parsed byte positions: {positions:?}");
assert_eq!(positions.len() % 2, 0); // Ensure there's an even number of positions
let dirnames: Vec<String> = positions
@ -4290,12 +4290,12 @@ fn test_ls_subdired_complex() {
let end_pos = chunk[1];
let dirname =
String::from_utf8(output.as_bytes()[start_pos..end_pos].to_vec()).unwrap();
println!("Extracted dirname: {}", dirname);
println!("Extracted dirname: {dirname}");
dirname
})
.collect();
println!("Extracted dirnames: {:?}", dirnames);
println!("Extracted dirnames: {dirnames:?}");
#[cfg(unix)]
assert_eq!(dirnames, vec!["dir1", "dir1/c2", "dir1/d"]);
#[cfg(windows)]
@ -4786,7 +4786,7 @@ fn test_acl_display() {
return;
}
Err(e) => {
println!("test skipped: setfacl failed with {}", e);
println!("test skipped: setfacl failed with {e}");
return;
}
}
@ -4874,7 +4874,7 @@ fn test_ls_color_norm() {
let expected = "\x1b[0m\x1b[07mnorm \x1b[0m\x1b[01mno_color\x1b[0m\n\x1b[07mnorm \x1b[0m\x1b[01;32mexe\x1b[0m\n"; // spell-checker:disable-line
scene
.ucmd()
.env("LS_COLORS", format!("{}:fi=1", colors))
.env("LS_COLORS", format!("{colors}:fi=1"))
.env("TIME_STYLE", "+norm")
.arg("-gGU")
.arg("--color")
@ -4889,7 +4889,7 @@ fn test_ls_color_norm() {
"\x1b[0m\x1b[07mnorm \x1b[0mno_color\x1b[0m\n\x1b[07mnorm \x1b[0m\x1b[01;32mexe\x1b[0m\n"; // spell-checker:disable-line
scene
.ucmd()
.env("LS_COLORS", format!("{}:fi=", colors))
.env("LS_COLORS", format!("{colors}:fi="))
.env("TIME_STYLE", "+norm")
.arg("-gGU")
.arg("--color")
@ -4903,7 +4903,7 @@ fn test_ls_color_norm() {
"\x1b[0m\x1b[07mnorm \x1b[0mno_color\x1b[0m\n\x1b[07mnorm \x1b[0m\x1b[01;32mexe\x1b[0m\n"; // spell-checker:disable-line
scene
.ucmd()
.env("LS_COLORS", format!("{}:fi=0", colors))
.env("LS_COLORS", format!("{colors}:fi=0"))
.env("TIME_STYLE", "+norm")
.arg("-gGU")
.arg("--color")

View file

@ -1448,7 +1448,7 @@ fn test_mv_directory_into_subdirectory_of_itself_fails() {
// check that it also errors out with /
scene
.ucmd()
.arg(format!("{}/", dir1))
.arg(format!("{dir1}/"))
.arg(dir2)
.fails()
.stderr_contains(
@ -1601,7 +1601,7 @@ fn test_acl() {
return;
}
Err(e) => {
println!("test skipped: setfacl failed with {}", e);
println!("test skipped: setfacl failed with {e}");
return;
}
}

View file

@ -168,7 +168,7 @@ fn test_delimiter_list_ending_with_escaped_backslash() {
let (at, mut ucmd) = at_and_ucmd!();
let mut ins = vec![];
for (i, one_in) in ["a\n", "b\n"].iter().enumerate() {
let file = format!("in{}", i);
let file = format!("in{i}");
at.write(&file, one_in);
ins.push(file);
}

View file

@ -1052,17 +1052,16 @@ fn test_batch_size_too_large() {
let large_batch_size = "18446744073709551616";
TestScenario::new(util_name!())
.ucmd()
.arg(format!("--batch-size={}", large_batch_size))
.arg(format!("--batch-size={large_batch_size}"))
.fails()
.code_is(2)
.stderr_contains(format!(
"--batch-size argument '{}' too large",
large_batch_size
"--batch-size argument '{large_batch_size}' too large"
));
#[cfg(target_os = "linux")]
TestScenario::new(util_name!())
.ucmd()
.arg(format!("--batch-size={}", large_batch_size))
.arg(format!("--batch-size={large_batch_size}"))
.fails()
.code_is(2)
.stderr_contains("maximum --batch-size argument with current rlimit is");

View file

@ -3594,10 +3594,8 @@ fn test_when_argument_file_is_non_existent_unix_socket_address_then_error() {
assert!(result.is_ok());
#[cfg(all(not(target_os = "freebsd"), not(target_os = "macos")))]
let expected_stderr = format!(
"tail: cannot open '{}' for reading: No such device or address\n",
socket
);
let expected_stderr =
format!("tail: cannot open '{socket}' for reading: No such device or address\n");
#[cfg(target_os = "freebsd")]
let expected_stderr = format!(
"tail: cannot open '{}' for reading: Operation not supported\n",
@ -3622,7 +3620,7 @@ fn test_when_argument_file_is_non_existent_unix_socket_address_then_error() {
let result = file.write_all(random_string.as_bytes());
assert!(result.is_ok());
let expected_stdout = [format!("==> {} <==", path), random_string].join("\n");
let expected_stdout = [format!("==> {path} <=="), random_string].join("\n");
ts.ucmd()
.args(&["-c", "+0", path, socket])
.fails()