mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
chore: manual inline formatting
Minor manual cleanup - inlined many format args. This makes the code a bit more readable, and helps spot a few inefficiencies and possible bugs. Note that `&foo` in a `format!` parameter results in a 6% extra performance cost, and does not get inlined by the compiler (yet).
This commit is contained in:
parent
b7bf8c9467
commit
982805d3cd
29 changed files with 133 additions and 183 deletions
|
@ -596,7 +596,7 @@ fn get_file_context(path: impl AsRef<Path>) -> Result<Option<String>, selinux::e
|
|||
let path = path.as_ref();
|
||||
match selinux::SecurityContext::of_path(path, false, false) {
|
||||
Err(r) => {
|
||||
println!("get_file_context failed: '{}': {}.", path.display(), &r);
|
||||
println!("get_file_context failed: '{}': {r}.", path.display());
|
||||
Err(r)
|
||||
}
|
||||
|
||||
|
@ -615,7 +615,7 @@ fn get_file_context(path: impl AsRef<Path>) -> Result<Option<String>, selinux::e
|
|||
.next()
|
||||
.unwrap_or_default();
|
||||
let context = String::from_utf8(bytes.into()).unwrap_or_default();
|
||||
println!("get_file_context: '{}' => '{}'.", context, path.display());
|
||||
println!("get_file_context: '{context}' => '{}'.", path.display());
|
||||
Ok(Some(context))
|
||||
}
|
||||
}
|
||||
|
@ -632,13 +632,11 @@ fn set_file_context(path: impl AsRef<Path>, context: &str) -> Result<(), selinux
|
|||
selinux::SecurityContext::from_c_str(&c_context, false).set_for_path(path, false, false);
|
||||
if let Err(r) = &r {
|
||||
println!(
|
||||
"set_file_context failed: '{}' => '{}': {}.",
|
||||
context,
|
||||
"set_file_context failed: '{context}' => '{}': {r}.",
|
||||
path.display(),
|
||||
r
|
||||
);
|
||||
} else {
|
||||
println!("set_file_context: '{}' => '{}'.", context, path.display());
|
||||
println!("set_file_context: '{context}' => '{}'.", path.display());
|
||||
}
|
||||
r
|
||||
}
|
||||
|
|
|
@ -101,8 +101,7 @@ fn test_preserve_root() {
|
|||
"./../../../../../../../../../../../../../../",
|
||||
] {
|
||||
let expected_error = format!(
|
||||
"chgrp: it is dangerous to operate recursively on '{}' (same as '/')\nchgrp: use --no-preserve-root to override this failsafe\n",
|
||||
d,
|
||||
"chgrp: it is dangerous to operate recursively on '{d}' (same as '/')\nchgrp: use --no-preserve-root to override this failsafe\n",
|
||||
);
|
||||
new_ucmd!()
|
||||
.arg("--preserve-root")
|
||||
|
|
|
@ -40,10 +40,9 @@ fn run_single_test(test: &TestCase, at: &AtPath, mut ucmd: UCommand) {
|
|||
|
||||
assert!(
|
||||
perms == test.before,
|
||||
"{}: expected: {:o} got: {:o}",
|
||||
"{}: expected: {:o} got: {perms:o}",
|
||||
"setting permissions on test files before actual test run failed",
|
||||
test.after,
|
||||
perms
|
||||
);
|
||||
|
||||
for arg in &test.args {
|
||||
|
@ -61,10 +60,8 @@ fn run_single_test(test: &TestCase, at: &AtPath, mut ucmd: UCommand) {
|
|||
let perms = at.metadata(TEST_FILE).permissions().mode();
|
||||
assert!(
|
||||
perms == test.after,
|
||||
"{}: expected: {:o} got: {:o}",
|
||||
ucmd,
|
||||
"{ucmd}: expected: {:o} got: {perms:o}",
|
||||
test.after,
|
||||
perms
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -243,8 +240,7 @@ fn test_chmod_umask_expected() {
|
|||
let current_umask = uucore::mode::get_umask();
|
||||
assert_eq!(
|
||||
current_umask, 0o022,
|
||||
"Unexpected umask value: expected 022 (octal), but got {:03o}. Please adjust the test environment.",
|
||||
current_umask
|
||||
"Unexpected umask value: expected 022 (octal), but got {current_umask:03o}. Please adjust the test environment.",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -847,7 +843,7 @@ fn test_chmod_symlink_to_dangling_target_dereference() {
|
|||
.arg("u+x")
|
||||
.arg(symlink)
|
||||
.fails()
|
||||
.stderr_contains(format!("cannot operate on dangling symlink '{}'", symlink));
|
||||
.stderr_contains(format!("cannot operate on dangling symlink '{symlink}'"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1019,8 +1015,7 @@ fn test_chmod_traverse_symlink_combo() {
|
|||
let actual_target = at.metadata(target).permissions().mode();
|
||||
assert_eq!(
|
||||
actual_target, expected_target_perms,
|
||||
"For flags {:?}, expected target perms = {:o}, got = {:o}",
|
||||
flags, expected_target_perms, actual_target
|
||||
"For flags {flags:?}, expected target perms = {expected_target_perms:o}, got = {actual_target:o}",
|
||||
);
|
||||
|
||||
let actual_symlink = at
|
||||
|
@ -1029,8 +1024,7 @@ fn test_chmod_traverse_symlink_combo() {
|
|||
.mode();
|
||||
assert_eq!(
|
||||
actual_symlink, expected_symlink_perms,
|
||||
"For flags {:?}, expected symlink perms = {:o}, got = {:o}",
|
||||
flags, expected_symlink_perms, actual_symlink
|
||||
"For flags {flags:?}, expected symlink perms = {expected_symlink_perms:o}, got = {actual_symlink:o}",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1722,7 +1722,7 @@ mod gnu_cksum_base64 {
|
|||
if ["sysv", "bsd", "crc", "crc32b"].contains(&algo) {
|
||||
digest.to_string()
|
||||
} else {
|
||||
format!("{} (f) = {}", algo.to_uppercase(), digest).replace("BLAKE2B", "BLAKE2b")
|
||||
format!("{} (f) = {digest}", algo.to_uppercase()).replace("BLAKE2B", "BLAKE2b")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2040,31 +2040,31 @@ fn test_cp_deref_folder_to_folder() {
|
|||
// No action as this test is disabled but kept in case we want to
|
||||
// try to make it work in the future.
|
||||
let a = Command::new("cmd").args(&["/C", "dir"]).output();
|
||||
println!("output {:#?}", a);
|
||||
println!("output {a:#?}");
|
||||
|
||||
let a = Command::new("cmd")
|
||||
.args(&["/C", "dir", &at.as_string()])
|
||||
.output();
|
||||
println!("output {:#?}", a);
|
||||
println!("output {a:#?}");
|
||||
|
||||
let a = Command::new("cmd")
|
||||
.args(&["/C", "dir", path_to_new_symlink.to_str().unwrap()])
|
||||
.output();
|
||||
println!("output {:#?}", a);
|
||||
println!("output {a:#?}");
|
||||
|
||||
let path_to_new_symlink = at.subdir.join(TEST_COPY_FROM_FOLDER);
|
||||
|
||||
let a = Command::new("cmd")
|
||||
.args(&["/C", "dir", path_to_new_symlink.to_str().unwrap()])
|
||||
.output();
|
||||
println!("output {:#?}", a);
|
||||
println!("output {a:#?}");
|
||||
|
||||
let path_to_new_symlink = at.subdir.join(TEST_COPY_TO_FOLDER_NEW);
|
||||
|
||||
let a = Command::new("cmd")
|
||||
.args(&["/C", "dir", path_to_new_symlink.to_str().unwrap()])
|
||||
.output();
|
||||
println!("output {:#?}", a);
|
||||
println!("output {a:#?}");
|
||||
}
|
||||
|
||||
let path_to_new_symlink = at
|
||||
|
@ -2138,31 +2138,31 @@ fn test_cp_no_deref_folder_to_folder() {
|
|||
// No action as this test is disabled but kept in case we want to
|
||||
// try to make it work in the future.
|
||||
let a = Command::new("cmd").args(&["/C", "dir"]).output();
|
||||
println!("output {:#?}", a);
|
||||
println!("output {a:#?}");
|
||||
|
||||
let a = Command::new("cmd")
|
||||
.args(&["/C", "dir", &at.as_string()])
|
||||
.output();
|
||||
println!("output {:#?}", a);
|
||||
println!("output {a:#?}");
|
||||
|
||||
let a = Command::new("cmd")
|
||||
.args(&["/C", "dir", path_to_new_symlink.to_str().unwrap()])
|
||||
.output();
|
||||
println!("output {:#?}", a);
|
||||
println!("output {a:#?}");
|
||||
|
||||
let path_to_new_symlink = at.subdir.join(TEST_COPY_FROM_FOLDER);
|
||||
|
||||
let a = Command::new("cmd")
|
||||
.args(&["/C", "dir", path_to_new_symlink.to_str().unwrap()])
|
||||
.output();
|
||||
println!("output {:#?}", a);
|
||||
println!("output {a:#?}");
|
||||
|
||||
let path_to_new_symlink = at.subdir.join(TEST_COPY_TO_FOLDER_NEW);
|
||||
|
||||
let a = Command::new("cmd")
|
||||
.args(&["/C", "dir", path_to_new_symlink.to_str().unwrap()])
|
||||
.output();
|
||||
println!("output {:#?}", a);
|
||||
println!("output {a:#?}");
|
||||
}
|
||||
|
||||
let path_to_new_symlink = at
|
||||
|
@ -2552,7 +2552,7 @@ fn test_closes_file_descriptors() {
|
|||
// For debugging purposes:
|
||||
for f in me.fd().unwrap() {
|
||||
let fd = f.unwrap();
|
||||
println!("{:?} {:?}", fd, fd.mode());
|
||||
println!("{fd:?} {:?}", fd.mode());
|
||||
}
|
||||
|
||||
new_ucmd!()
|
||||
|
@ -6093,9 +6093,7 @@ fn test_cp_preserve_xattr_readonly_source() {
|
|||
let stdout = String::from_utf8_lossy(&getfattr_output.stdout);
|
||||
assert!(
|
||||
stdout.contains(xattr_key),
|
||||
"Expected '{}' not found in getfattr output:\n{}",
|
||||
xattr_key,
|
||||
stdout
|
||||
"Expected '{xattr_key}' not found in getfattr output:\n{stdout}"
|
||||
);
|
||||
|
||||
at.set_readonly(source_file);
|
||||
|
|
|
@ -1457,7 +1457,7 @@ fn create_named_pipe_with_writer(path: &str, data: &str) -> std::process::Child
|
|||
nix::unistd::mkfifo(path, nix::sys::stat::Mode::S_IRWXU).unwrap();
|
||||
std::process::Command::new("sh")
|
||||
.arg("-c")
|
||||
.arg(format!("printf '{}' > {path}", data))
|
||||
.arg(format!("printf '{data}' > {path}"))
|
||||
.spawn()
|
||||
.unwrap()
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ macro_rules! fixture_path {
|
|||
macro_rules! assert_fixture_exists {
|
||||
($fname:expr) => {{
|
||||
let fpath = fixture_path!($fname);
|
||||
assert!(fpath.exists(), "Fixture missing: {:?}", fpath);
|
||||
assert!(fpath.exists(), "Fixture missing: {fpath:?}");
|
||||
}};
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ macro_rules! assert_fixture_exists {
|
|||
macro_rules! assert_fixture_not_exists {
|
||||
($fname:expr) => {{
|
||||
let fpath = PathBuf::from(format!("./fixtures/dd/{}", $fname));
|
||||
assert!(!fpath.exists(), "Fixture present: {:?}", fpath);
|
||||
assert!(!fpath.exists(), "Fixture present: {fpath:?}");
|
||||
}};
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,7 @@ fn test_null_fullblock() {
|
|||
#[test]
|
||||
fn test_fullblock() {
|
||||
let tname = "fullblock-from-urand";
|
||||
let tmp_fn = format!("TESTFILE-{}.tmp", &tname);
|
||||
let tmp_fn = format!("TESTFILE-{tname}.tmp");
|
||||
let exp_stats = vec![
|
||||
"1+0 records in\n",
|
||||
"1+0 records out\n",
|
||||
|
@ -458,11 +458,11 @@ fn test_zeros_to_stdout() {
|
|||
fn test_oversized_bs_32_bit() {
|
||||
for bs_param in ["bs", "ibs", "obs", "cbs"] {
|
||||
new_ucmd!()
|
||||
.args(&[format!("{}=5GB", bs_param)])
|
||||
.args(&[format!("{bs_param}=5GB")])
|
||||
.fails()
|
||||
.no_stdout()
|
||||
.code_is(1)
|
||||
.stderr_is(format!("dd: {}=N cannot fit into memory\n", bs_param));
|
||||
.stderr_is(format!("dd: {bs_param}=N cannot fit into memory\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -493,7 +493,7 @@ fn test_ascii_10k_to_stdout() {
|
|||
fn test_zeros_to_file() {
|
||||
let tname = "zero-256k";
|
||||
let test_fn = format!("{tname}.txt");
|
||||
let tmp_fn = format!("TESTFILE-{}.tmp", &tname);
|
||||
let tmp_fn = format!("TESTFILE-{tname}.tmp");
|
||||
assert_fixture_exists!(test_fn);
|
||||
|
||||
let (fix, mut ucmd) = at_and_ucmd!();
|
||||
|
@ -511,7 +511,7 @@ fn test_zeros_to_file() {
|
|||
fn test_to_file_with_ibs_obs() {
|
||||
let tname = "zero-256k";
|
||||
let test_fn = format!("{tname}.txt");
|
||||
let tmp_fn = format!("TESTFILE-{}.tmp", &tname);
|
||||
let tmp_fn = format!("TESTFILE-{tname}.tmp");
|
||||
assert_fixture_exists!(test_fn);
|
||||
|
||||
let (fix, mut ucmd) = at_and_ucmd!();
|
||||
|
@ -535,7 +535,7 @@ fn test_to_file_with_ibs_obs() {
|
|||
fn test_ascii_521k_to_file() {
|
||||
let tname = "ascii-521k";
|
||||
let input = build_ascii_block(512 * 1024);
|
||||
let tmp_fn = format!("TESTFILE-{}.tmp", &tname);
|
||||
let tmp_fn = format!("TESTFILE-{tname}.tmp");
|
||||
|
||||
let (fix, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.args(&["status=none", &of!(tmp_fn)])
|
||||
|
@ -560,7 +560,7 @@ fn test_ascii_521k_to_file() {
|
|||
#[test]
|
||||
fn test_ascii_5_gibi_to_file() {
|
||||
let tname = "ascii-5G";
|
||||
let tmp_fn = format!("TESTFILE-{}.tmp", &tname);
|
||||
let tmp_fn = format!("TESTFILE-{tname}.tmp");
|
||||
|
||||
let (fix, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.args(&[
|
||||
|
@ -597,7 +597,7 @@ fn test_self_transfer() {
|
|||
fn test_unicode_filenames() {
|
||||
let tname = "😎💚🦊";
|
||||
let test_fn = format!("{tname}.txt");
|
||||
let tmp_fn = format!("TESTFILE-{}.tmp", &tname);
|
||||
let tmp_fn = format!("TESTFILE-{tname}.tmp");
|
||||
assert_fixture_exists!(test_fn);
|
||||
|
||||
let (fix, mut ucmd) = at_and_ucmd!();
|
||||
|
|
|
@ -585,11 +585,7 @@ fn test_du_h_precision() {
|
|||
.arg("--apparent-size")
|
||||
.arg(&fpath)
|
||||
.succeeds()
|
||||
.stdout_only(format!(
|
||||
"{}\t{}\n",
|
||||
expected_output,
|
||||
&fpath.to_string_lossy()
|
||||
));
|
||||
.stdout_only(format!("{expected_output}\t{}\n", fpath.to_string_lossy()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -659,7 +655,7 @@ fn birth_supported() -> bool {
|
|||
let ts = TestScenario::new(util_name!());
|
||||
let m = match std::fs::metadata(&ts.fixtures.subdir) {
|
||||
Ok(m) => m,
|
||||
Err(e) => panic!("{}", e),
|
||||
Err(e) => panic!("{e}"),
|
||||
};
|
||||
m.created().is_ok()
|
||||
}
|
||||
|
|
|
@ -435,7 +435,7 @@ fn test_all_but_last_bytes_large_file_piped() {
|
|||
.len();
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-c", &format!("-{}", seq_19001_20000_file_length)])
|
||||
.args(&["-c", &format!("-{seq_19001_20000_file_length}")])
|
||||
.pipe_in_fixture(seq_20000_file_name)
|
||||
.succeeds()
|
||||
.stdout_only_fixture(seq_19000_file_name);
|
||||
|
@ -695,7 +695,7 @@ fn test_validate_stdin_offset_bytes() {
|
|||
.len();
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-c", &format!("-{}", seq_19001_20000_file_length)])
|
||||
.args(&["-c", &format!("-{seq_19001_20000_file_length}")])
|
||||
.set_stdin(file)
|
||||
.succeeds()
|
||||
.stdout_only_fixture(seq_19000_file_name);
|
||||
|
|
|
@ -1670,7 +1670,7 @@ fn test_target_file_ends_with_slash() {
|
|||
let source = "source_file";
|
||||
let target_dir = "dir";
|
||||
let target_file = "dir/target_file";
|
||||
let target_file_slash = format!("{}/", target_file);
|
||||
let target_file_slash = format!("{target_file}/");
|
||||
|
||||
at.touch(source);
|
||||
at.mkdir(target_dir);
|
||||
|
|
|
@ -429,7 +429,7 @@ fn test_symlink_implicit_target_dir() {
|
|||
fn test_symlink_to_dir_2args() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let filename = "test_symlink_to_dir_2args_file";
|
||||
let from_file = &format!("{}/{}", at.as_string(), filename);
|
||||
let from_file = &format!("{}/{filename}", at.as_string());
|
||||
let to_dir = "test_symlink_to_dir_2args_to_dir";
|
||||
let to_file = &format!("{to_dir}/{filename}");
|
||||
|
||||
|
@ -493,7 +493,7 @@ fn test_symlink_relative_path() {
|
|||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.args(&["-s", "-v", &p.to_string_lossy(), link])
|
||||
.succeeds()
|
||||
.stdout_only(format!("'{}' -> '{}'\n", link, &p.to_string_lossy()));
|
||||
.stdout_only(format!("'{link}' -> '{}'\n", p.to_string_lossy()));
|
||||
assert!(at.is_symlink(link));
|
||||
assert_eq!(at.resolve_link(link), p.to_string_lossy());
|
||||
}
|
||||
|
|
|
@ -2247,14 +2247,12 @@ mod quoting {
|
|||
at.mkdir(dirname);
|
||||
|
||||
let expected = format!(
|
||||
"{}:\n{}\n\n{}:\n",
|
||||
"{}:\n{regular_mode}\n\n{dir_mode}:\n",
|
||||
match *qt_style {
|
||||
"shell-always" | "shell-escape-always" => "'.'",
|
||||
"c" => "\".\"",
|
||||
_ => ".",
|
||||
},
|
||||
regular_mode,
|
||||
dir_mode
|
||||
);
|
||||
|
||||
scene
|
||||
|
@ -4051,7 +4049,7 @@ fn test_ls_path() {
|
|||
.succeeds()
|
||||
.stdout_is(expected_stdout);
|
||||
|
||||
let abs_path = format!("{}/{}", at.as_string(), path);
|
||||
let abs_path = format!("{}/{path}", at.as_string());
|
||||
let expected_stdout = format!("{abs_path}\n");
|
||||
|
||||
scene
|
||||
|
@ -4160,7 +4158,7 @@ fn test_ls_context1() {
|
|||
}
|
||||
|
||||
let file = "test_ls_context_file";
|
||||
let expected = format!("unconfined_u:object_r:user_tmp_t:s0 {}\n", file);
|
||||
let expected = format!("unconfined_u:object_r:user_tmp_t:s0 {file}\n");
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
at.touch(file);
|
||||
ucmd.args(&["-Z", file]).succeeds().stdout_is(expected);
|
||||
|
@ -4204,7 +4202,7 @@ fn test_ls_context_format() {
|
|||
// "verbose",
|
||||
"vertical",
|
||||
] {
|
||||
let format = format!("--format={}", word);
|
||||
let format = format!("--format={word}");
|
||||
ts.ucmd()
|
||||
.args(&["-Z", format.as_str(), "/"])
|
||||
.succeeds()
|
||||
|
|
|
@ -57,9 +57,8 @@ macro_rules! assert_suffix_matches_template {
|
|||
let suffix = &$s[n - m..n];
|
||||
assert!(
|
||||
matches_template($template, suffix),
|
||||
"\"{}\" does not end with \"{}\"",
|
||||
"\"{}\" does not end with \"{suffix}\"",
|
||||
$template,
|
||||
suffix
|
||||
);
|
||||
}};
|
||||
}
|
||||
|
@ -780,13 +779,11 @@ fn test_nonexistent_tmpdir_env_var() {
|
|||
let stderr = result.stderr_str();
|
||||
assert!(
|
||||
stderr.starts_with("mktemp: failed to create file via template"),
|
||||
"{}",
|
||||
stderr
|
||||
"{stderr}",
|
||||
);
|
||||
assert!(
|
||||
stderr.ends_with("no\\such\\dir\\tmp.XXXXXXXXXX': No such file or directory\n"),
|
||||
"{}",
|
||||
stderr
|
||||
"{stderr}",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -799,13 +796,11 @@ fn test_nonexistent_tmpdir_env_var() {
|
|||
let stderr = result.stderr_str();
|
||||
assert!(
|
||||
stderr.starts_with("mktemp: failed to create directory via template"),
|
||||
"{}",
|
||||
stderr
|
||||
"{stderr}",
|
||||
);
|
||||
assert!(
|
||||
stderr.ends_with("no\\such\\dir\\tmp.XXXXXXXXXX': No such file or directory\n"),
|
||||
"{}",
|
||||
stderr
|
||||
"{stderr}",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -823,13 +818,11 @@ fn test_nonexistent_dir_prefix() {
|
|||
let stderr = result.stderr_str();
|
||||
assert!(
|
||||
stderr.starts_with("mktemp: failed to create file via template"),
|
||||
"{}",
|
||||
stderr
|
||||
"{stderr}",
|
||||
);
|
||||
assert!(
|
||||
stderr.ends_with("d\\XXX': No such file or directory\n"),
|
||||
"{}",
|
||||
stderr
|
||||
"{stderr}",
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -844,13 +837,11 @@ fn test_nonexistent_dir_prefix() {
|
|||
let stderr = result.stderr_str();
|
||||
assert!(
|
||||
stderr.starts_with("mktemp: failed to create directory via template"),
|
||||
"{}",
|
||||
stderr
|
||||
"{stderr}",
|
||||
);
|
||||
assert!(
|
||||
stderr.ends_with("d\\XXX': No such file or directory\n"),
|
||||
"{}",
|
||||
stderr
|
||||
"{stderr}",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -385,44 +385,44 @@ fn test_realpath_trailing_slash() {
|
|||
.ucmd()
|
||||
.arg("link_file")
|
||||
.succeeds()
|
||||
.stdout_contains(format!("{}file\n", std::path::MAIN_SEPARATOR));
|
||||
.stdout_contains(format!("{MAIN_SEPARATOR}file\n"));
|
||||
scene.ucmd().arg("link_file/").fails_with_code(1);
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("link_dir")
|
||||
.succeeds()
|
||||
.stdout_contains(format!("{}dir\n", std::path::MAIN_SEPARATOR));
|
||||
.stdout_contains(format!("{MAIN_SEPARATOR}dir\n"));
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("link_dir/")
|
||||
.succeeds()
|
||||
.stdout_contains(format!("{}dir\n", std::path::MAIN_SEPARATOR));
|
||||
.stdout_contains(format!("{MAIN_SEPARATOR}dir\n"));
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("link_no_dir")
|
||||
.succeeds()
|
||||
.stdout_contains(format!("{}no_dir\n", std::path::MAIN_SEPARATOR));
|
||||
.stdout_contains(format!("{MAIN_SEPARATOR}no_dir\n"));
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("link_no_dir/")
|
||||
.succeeds()
|
||||
.stdout_contains(format!("{}no_dir\n", std::path::MAIN_SEPARATOR));
|
||||
.stdout_contains(format!("{MAIN_SEPARATOR}no_dir\n"));
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-e", "link_file"])
|
||||
.succeeds()
|
||||
.stdout_contains(format!("{}file\n", std::path::MAIN_SEPARATOR));
|
||||
.stdout_contains(format!("{MAIN_SEPARATOR}file\n"));
|
||||
scene.ucmd().args(&["-e", "link_file/"]).fails_with_code(1);
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-e", "link_dir"])
|
||||
.succeeds()
|
||||
.stdout_contains(format!("{}dir\n", std::path::MAIN_SEPARATOR));
|
||||
.stdout_contains(format!("{MAIN_SEPARATOR}dir\n"));
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-e", "link_dir/"])
|
||||
.succeeds()
|
||||
.stdout_contains(format!("{}dir\n", std::path::MAIN_SEPARATOR));
|
||||
.stdout_contains(format!("{MAIN_SEPARATOR}dir\n"));
|
||||
scene.ucmd().args(&["-e", "link_no_dir"]).fails_with_code(1);
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -432,32 +432,32 @@ fn test_realpath_trailing_slash() {
|
|||
.ucmd()
|
||||
.args(&["-m", "link_file"])
|
||||
.succeeds()
|
||||
.stdout_contains(format!("{}file\n", std::path::MAIN_SEPARATOR));
|
||||
.stdout_contains(format!("{MAIN_SEPARATOR}file\n"));
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-m", "link_file/"])
|
||||
.succeeds()
|
||||
.stdout_contains(format!("{}file\n", std::path::MAIN_SEPARATOR));
|
||||
.stdout_contains(format!("{MAIN_SEPARATOR}file\n"));
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-m", "link_dir"])
|
||||
.succeeds()
|
||||
.stdout_contains(format!("{}dir\n", std::path::MAIN_SEPARATOR));
|
||||
.stdout_contains(format!("{MAIN_SEPARATOR}dir\n"));
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-m", "link_dir/"])
|
||||
.succeeds()
|
||||
.stdout_contains(format!("{}dir\n", std::path::MAIN_SEPARATOR));
|
||||
.stdout_contains(format!("{MAIN_SEPARATOR}dir\n"));
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-m", "link_no_dir"])
|
||||
.succeeds()
|
||||
.stdout_contains(format!("{}no_dir\n", std::path::MAIN_SEPARATOR));
|
||||
.stdout_contains(format!("{MAIN_SEPARATOR}no_dir\n"));
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-m", "link_no_dir/"])
|
||||
.succeeds()
|
||||
.stdout_contains(format!("{}no_dir\n", std::path::MAIN_SEPARATOR));
|
||||
.stdout_contains(format!("{MAIN_SEPARATOR}no_dir\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -333,8 +333,7 @@ fn test_rm_verbose_slash() {
|
|||
at.touch(file_a);
|
||||
|
||||
let file_a_normalized = &format!(
|
||||
"{}{}test_rm_verbose_slash_file_a",
|
||||
dir,
|
||||
"{dir}{}test_rm_verbose_slash_file_a",
|
||||
std::path::MAIN_SEPARATOR
|
||||
);
|
||||
|
||||
|
|
|
@ -105,8 +105,7 @@ fn test_invalid_buffer_size() {
|
|||
.arg("ext_sort.txt")
|
||||
.fails_with_code(2)
|
||||
.stderr_only(format!(
|
||||
"sort: --buffer-size argument '{}' too large\n",
|
||||
buffer_size
|
||||
"sort: --buffer-size argument '{buffer_size}' too large\n"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,10 +248,7 @@ fn test_timestamp_format() {
|
|||
assert_eq!(
|
||||
result,
|
||||
format!("{expected}\n"),
|
||||
"Format '{}' failed.\nExpected: '{}'\nGot: '{}'",
|
||||
format_str,
|
||||
expected,
|
||||
result,
|
||||
"Format '{format_str}' failed.\nExpected: '{expected}'\nGot: '{result}'",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1801,12 +1801,12 @@ fn test_follow_name_remove() {
|
|||
let expected_stdout = at.read(FOLLOW_NAME_SHORT_EXP);
|
||||
let expected_stderr = [
|
||||
format!(
|
||||
"{}: {}: No such file or directory\n{0}: no files remaining\n",
|
||||
ts.util_name, source_copy
|
||||
"{}: {source_copy}: No such file or directory\n{0}: no files remaining\n",
|
||||
ts.util_name,
|
||||
),
|
||||
format!(
|
||||
"{}: {}: No such file or directory\n",
|
||||
ts.util_name, source_copy
|
||||
"{}: {source_copy}: No such file or directory\n",
|
||||
ts.util_name,
|
||||
),
|
||||
];
|
||||
|
||||
|
@ -1862,7 +1862,7 @@ fn test_follow_name_truncate1() {
|
|||
let backup = "backup";
|
||||
|
||||
let expected_stdout = at.read(FOLLOW_NAME_EXP);
|
||||
let expected_stderr = format!("{}: {}: file truncated\n", ts.util_name, source);
|
||||
let expected_stderr = format!("{}: {source}: file truncated\n", ts.util_name);
|
||||
|
||||
let args = ["--follow=name", source];
|
||||
let mut p = ts.ucmd().args(&args).run_no_wait();
|
||||
|
@ -1904,7 +1904,7 @@ fn test_follow_name_truncate2() {
|
|||
at.touch(source);
|
||||
|
||||
let expected_stdout = "x\nx\nx\nx\n";
|
||||
let expected_stderr = format!("{}: {}: file truncated\n", ts.util_name, source);
|
||||
let expected_stderr = format!("{}: {source}: file truncated\n", ts.util_name);
|
||||
|
||||
let args = ["--follow=name", source];
|
||||
let mut p = ts.ucmd().args(&args).run_no_wait();
|
||||
|
@ -2071,8 +2071,8 @@ fn test_follow_name_move_create1() {
|
|||
|
||||
#[cfg(target_os = "linux")]
|
||||
let expected_stderr = format!(
|
||||
"{}: {}: No such file or directory\n{0}: '{1}' has appeared; following new file\n",
|
||||
ts.util_name, source
|
||||
"{}: {source}: No such file or directory\n{0}: '{source}' has appeared; following new file\n",
|
||||
ts.util_name,
|
||||
);
|
||||
|
||||
// NOTE: We are less strict if not on Linux (inotify backend).
|
||||
|
@ -2081,7 +2081,7 @@ fn test_follow_name_move_create1() {
|
|||
let expected_stdout = at.read(FOLLOW_NAME_SHORT_EXP);
|
||||
|
||||
#[cfg(not(target_os = "linux"))]
|
||||
let expected_stderr = format!("{}: {}: No such file or directory\n", ts.util_name, source);
|
||||
let expected_stderr = format!("{}: {source}: No such file or directory\n", ts.util_name);
|
||||
|
||||
let delay = 500;
|
||||
let args = ["--follow=name", source];
|
||||
|
@ -2205,10 +2205,10 @@ fn test_follow_name_move1() {
|
|||
|
||||
let expected_stdout = at.read(FOLLOW_NAME_SHORT_EXP);
|
||||
let expected_stderr = [
|
||||
format!("{}: {}: No such file or directory\n", ts.util_name, source),
|
||||
format!("{}: {source}: No such file or directory\n", ts.util_name),
|
||||
format!(
|
||||
"{}: {}: No such file or directory\n{0}: no files remaining\n",
|
||||
ts.util_name, source
|
||||
"{}: {source}: No such file or directory\n{0}: no files remaining\n",
|
||||
ts.util_name,
|
||||
),
|
||||
];
|
||||
|
||||
|
@ -3558,15 +3558,11 @@ fn test_when_argument_file_is_non_existent_unix_socket_address_then_error() {
|
|||
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",
|
||||
socket
|
||||
);
|
||||
let expected_stderr =
|
||||
format!("tail: cannot open '{socket}' for reading: Operation not supported\n",);
|
||||
#[cfg(target_os = "macos")]
|
||||
let expected_stderr = format!(
|
||||
"tail: cannot open '{}' for reading: Operation not supported on socket\n",
|
||||
socket
|
||||
);
|
||||
let expected_stderr =
|
||||
format!("tail: cannot open '{socket}' for reading: Operation not supported on socket\n",);
|
||||
|
||||
ts.ucmd()
|
||||
.arg(socket)
|
||||
|
|
|
@ -243,8 +243,7 @@ mod linux_only {
|
|||
);
|
||||
assert!(
|
||||
result.stderr_str().contains(message),
|
||||
"Expected to see error message fragment {} in stderr, but did not.\n stderr = {}",
|
||||
message,
|
||||
"Expected to see error message fragment {message} in stderr, but did not.\n stderr = {}",
|
||||
std::str::from_utf8(result.stderr()).unwrap(),
|
||||
);
|
||||
}
|
||||
|
@ -274,9 +273,8 @@ mod linux_only {
|
|||
let compare = at.read(name);
|
||||
assert!(
|
||||
compare.len() < contents.len(),
|
||||
"Too many bytes ({}) written to {} (should be a short count from {})",
|
||||
"Too many bytes ({}) written to {name} (should be a short count from {})",
|
||||
compare.len(),
|
||||
name,
|
||||
contents.len()
|
||||
);
|
||||
assert!(
|
||||
|
|
|
@ -824,8 +824,7 @@ fn test_touch_permission_denied_error_msg() {
|
|||
|
||||
let full_path = at.plus_as_string(path_str);
|
||||
ucmd.arg(&full_path).fails().stderr_only(format!(
|
||||
"touch: cannot touch '{}': Permission denied\n",
|
||||
&full_path
|
||||
"touch: cannot touch '{full_path}': Permission denied\n",
|
||||
));
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue