mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-09-15 19:36:16 +00:00
clippy: fix warnings introduced with Rust 1.67.0
This commit is contained in:
parent
fc7e51a4f8
commit
f6b646e4e5
172 changed files with 835 additions and 1034 deletions
|
@ -118,7 +118,7 @@ fn test_preserve_root_symlink() {
|
|||
at.symlink_file("///dev", file);
|
||||
ucmd.arg("--preserve-root")
|
||||
.arg("-HR")
|
||||
.arg("bin").arg(format!(".//{}/..//..//../../", file))
|
||||
.arg("bin").arg(format!(".//{file}/..//..//../../"))
|
||||
.fails()
|
||||
.stderr_is("chgrp: it is dangerous to operate recursively on '/'\nchgrp: use --no-preserve-root to override this failsafe\n");
|
||||
|
||||
|
|
|
@ -414,10 +414,9 @@ fn test_chmod_symlink_non_existing_file() {
|
|||
let non_existing = "test_chmod_symlink_non_existing_file";
|
||||
let test_symlink = "test_chmod_symlink_non_existing_file_symlink";
|
||||
let expected_stdout = &format!(
|
||||
"failed to change mode of '{}' from 0000 (---------) to 0000 (---------)",
|
||||
test_symlink
|
||||
"failed to change mode of '{test_symlink}' from 0000 (---------) to 0000 (---------)"
|
||||
);
|
||||
let expected_stderr = &format!("cannot operate on dangling symlink '{}'", test_symlink);
|
||||
let expected_stderr = &format!("cannot operate on dangling symlink '{test_symlink}'");
|
||||
|
||||
at.symlink_file(non_existing, test_symlink);
|
||||
|
||||
|
@ -455,10 +454,7 @@ fn test_chmod_symlink_non_existing_file_recursive() {
|
|||
let test_directory = "test_chmod_symlink_non_existing_file_directory";
|
||||
|
||||
at.mkdir(test_directory);
|
||||
at.symlink_file(
|
||||
non_existing,
|
||||
&format!("{}/{}", test_directory, test_symlink),
|
||||
);
|
||||
at.symlink_file(non_existing, &format!("{test_directory}/{test_symlink}"));
|
||||
|
||||
// this should succeed
|
||||
scene
|
||||
|
@ -472,8 +468,7 @@ fn test_chmod_symlink_non_existing_file_recursive() {
|
|||
|
||||
let expected_stdout = &format!(
|
||||
// spell-checker:disable-next-line
|
||||
"mode of '{}' retained as 0755 (rwxr-xr-x)",
|
||||
test_directory
|
||||
"mode of '{test_directory}' retained as 0755 (rwxr-xr-x)"
|
||||
);
|
||||
|
||||
// '-v': this should succeed without stderr
|
||||
|
|
|
@ -138,7 +138,7 @@ fn test_chown_only_owner_colon() {
|
|||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(format!("{}:", user_name))
|
||||
.arg(format!("{user_name}:"))
|
||||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.succeeds()
|
||||
|
@ -146,7 +146,7 @@ fn test_chown_only_owner_colon() {
|
|||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(format!("{}.", user_name))
|
||||
.arg(format!("{user_name}."))
|
||||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.succeeds()
|
||||
|
@ -244,7 +244,7 @@ fn test_chown_owner_group() {
|
|||
|
||||
let result = scene
|
||||
.ucmd()
|
||||
.arg(format!("{}:{}", user_name, group_name))
|
||||
.arg(format!("{user_name}:{group_name}"))
|
||||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.run();
|
||||
|
@ -309,7 +309,7 @@ fn test_chown_various_input() {
|
|||
|
||||
let result = scene
|
||||
.ucmd()
|
||||
.arg(format!("{}:{}", user_name, group_name))
|
||||
.arg(format!("{user_name}:{group_name}"))
|
||||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.run();
|
||||
|
@ -321,7 +321,7 @@ fn test_chown_various_input() {
|
|||
// check that username.groupname is understood
|
||||
let result = scene
|
||||
.ucmd()
|
||||
.arg(format!("{}.{}", user_name, group_name))
|
||||
.arg(format!("{user_name}.{group_name}"))
|
||||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.run();
|
||||
|
@ -365,7 +365,7 @@ fn test_chown_only_group() {
|
|||
|
||||
let result = scene
|
||||
.ucmd()
|
||||
.arg(format!(":{}", user_name))
|
||||
.arg(format!(":{user_name}"))
|
||||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.run();
|
||||
|
@ -442,14 +442,14 @@ fn test_chown_fail_id() {
|
|||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(format!("{}:", user_id))
|
||||
.arg(format!("{user_id}:"))
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains("invalid spec");
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(format!("{}.", user_id))
|
||||
.arg(format!("{user_id}."))
|
||||
.arg(file1)
|
||||
.fails()
|
||||
.stderr_contains("invalid spec");
|
||||
|
@ -499,7 +499,7 @@ fn test_chown_only_group_id() {
|
|||
|
||||
let result = scene
|
||||
.ucmd()
|
||||
.arg(format!(":{}", group_id))
|
||||
.arg(format!(":{group_id}"))
|
||||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.run();
|
||||
|
@ -570,7 +570,7 @@ fn test_chown_owner_group_id() {
|
|||
|
||||
let result = scene
|
||||
.ucmd()
|
||||
.arg(format!("{}:{}", user_id, group_id))
|
||||
.arg(format!("{user_id}:{group_id}"))
|
||||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.run();
|
||||
|
@ -583,7 +583,7 @@ fn test_chown_owner_group_id() {
|
|||
|
||||
let result = scene
|
||||
.ucmd()
|
||||
.arg(format!("{}.{}", user_id, group_id))
|
||||
.arg(format!("{user_id}.{group_id}"))
|
||||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.run();
|
||||
|
@ -631,7 +631,7 @@ fn test_chown_owner_group_mix() {
|
|||
|
||||
let result = scene
|
||||
.ucmd()
|
||||
.arg(format!("{}:{}", user_id, group_name))
|
||||
.arg(format!("{user_id}:{group_name}"))
|
||||
.arg("--verbose")
|
||||
.arg(file1)
|
||||
.run();
|
||||
|
|
|
@ -94,7 +94,7 @@ fn test_preference_of_userspec() {
|
|||
.arg("fake")
|
||||
.arg("-G")
|
||||
.arg("ABC,DEF")
|
||||
.arg(format!("--userspec={}:{}", username, group_name))
|
||||
.arg(format!("--userspec={username}:{group_name}"))
|
||||
.fails();
|
||||
|
||||
result.code_is(125);
|
||||
|
@ -113,10 +113,7 @@ fn test_default_shell() {
|
|||
at.mkdir(dir);
|
||||
|
||||
let shell = std::env::var("SHELL").unwrap_or_else(|_| "/bin/sh".to_string());
|
||||
let expected = format!(
|
||||
"chroot: failed to run command '{}': No such file or directory",
|
||||
shell
|
||||
);
|
||||
let expected = format!("chroot: failed to run command '{shell}': No such file or directory");
|
||||
|
||||
if let Ok(result) = run_ucmd_as_root(&ts, &[dir]) {
|
||||
result.stderr_contains(expected);
|
||||
|
|
|
@ -91,7 +91,7 @@ fn test_cp_existing_target() {
|
|||
assert_eq!(at.read(TEST_EXISTING_FILE), "Hello, World!\n");
|
||||
|
||||
// No backup should have been created
|
||||
assert!(!at.file_exists(&format!("{}~", TEST_EXISTING_FILE)));
|
||||
assert!(!at.file_exists(&format!("{TEST_EXISTING_FILE}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -211,7 +211,7 @@ fn test_cp_target_directory_is_file() {
|
|||
.arg(TEST_HOW_ARE_YOU_SOURCE)
|
||||
.arg(TEST_HELLO_WORLD_SOURCE)
|
||||
.fails()
|
||||
.stderr_contains(format!("'{}' is not a directory", TEST_HOW_ARE_YOU_SOURCE));
|
||||
.stderr_contains(format!("'{TEST_HOW_ARE_YOU_SOURCE}' is not a directory"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -374,7 +374,7 @@ fn test_cp_arg_backup() {
|
|||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
|
||||
assert_eq!(
|
||||
at.read(&format!("{}~", TEST_HOW_ARE_YOU_SOURCE)),
|
||||
at.read(&format!("{TEST_HOW_ARE_YOU_SOURCE}~")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -390,7 +390,7 @@ fn test_cp_arg_backup_with_other_args() {
|
|||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
|
||||
assert_eq!(
|
||||
at.read(&format!("{}~", TEST_HOW_ARE_YOU_SOURCE)),
|
||||
at.read(&format!("{TEST_HOW_ARE_YOU_SOURCE}~")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -406,7 +406,7 @@ fn test_cp_arg_backup_arg_first() {
|
|||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
|
||||
assert_eq!(
|
||||
at.read(&format!("{}~", TEST_HOW_ARE_YOU_SOURCE)),
|
||||
at.read(&format!("{TEST_HOW_ARE_YOU_SOURCE}~")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -424,7 +424,7 @@ fn test_cp_arg_suffix() {
|
|||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
|
||||
assert_eq!(
|
||||
at.read(&format!("{}.bak", TEST_HOW_ARE_YOU_SOURCE)),
|
||||
at.read(&format!("{TEST_HOW_ARE_YOU_SOURCE}.bak")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -442,7 +442,7 @@ fn test_cp_arg_suffix_hyphen_value() {
|
|||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
|
||||
assert_eq!(
|
||||
at.read(&format!("{}-v", TEST_HOW_ARE_YOU_SOURCE)),
|
||||
at.read(&format!("{TEST_HOW_ARE_YOU_SOURCE}-v")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -461,7 +461,7 @@ fn test_cp_custom_backup_suffix_via_env() {
|
|||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
|
||||
assert_eq!(
|
||||
at.read(&format!("{}{}", TEST_HOW_ARE_YOU_SOURCE, suffix)),
|
||||
at.read(&format!("{TEST_HOW_ARE_YOU_SOURCE}{suffix}")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -478,7 +478,7 @@ fn test_cp_backup_numbered_with_t() {
|
|||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
|
||||
assert_eq!(
|
||||
at.read(&format!("{}.~1~", TEST_HOW_ARE_YOU_SOURCE)),
|
||||
at.read(&format!("{TEST_HOW_ARE_YOU_SOURCE}.~1~")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -495,7 +495,7 @@ fn test_cp_backup_numbered() {
|
|||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
|
||||
assert_eq!(
|
||||
at.read(&format!("{}.~1~", TEST_HOW_ARE_YOU_SOURCE)),
|
||||
at.read(&format!("{TEST_HOW_ARE_YOU_SOURCE}.~1~")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -512,7 +512,7 @@ fn test_cp_backup_existing() {
|
|||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
|
||||
assert_eq!(
|
||||
at.read(&format!("{}~", TEST_HOW_ARE_YOU_SOURCE)),
|
||||
at.read(&format!("{TEST_HOW_ARE_YOU_SOURCE}~")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ fn test_cp_backup_nil() {
|
|||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
|
||||
assert_eq!(
|
||||
at.read(&format!("{}~", TEST_HOW_ARE_YOU_SOURCE)),
|
||||
at.read(&format!("{TEST_HOW_ARE_YOU_SOURCE}~")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -537,7 +537,7 @@ fn test_cp_backup_nil() {
|
|||
#[test]
|
||||
fn test_cp_numbered_if_existing_backup_existing() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let existing_backup = &format!("{}.~1~", TEST_HOW_ARE_YOU_SOURCE);
|
||||
let existing_backup = &format!("{TEST_HOW_ARE_YOU_SOURCE}.~1~");
|
||||
at.touch(existing_backup);
|
||||
|
||||
ucmd.arg("--backup=existing")
|
||||
|
@ -549,7 +549,7 @@ fn test_cp_numbered_if_existing_backup_existing() {
|
|||
assert!(at.file_exists(TEST_HOW_ARE_YOU_SOURCE));
|
||||
assert!(at.file_exists(existing_backup));
|
||||
assert_eq!(
|
||||
at.read(&format!("{}.~2~", TEST_HOW_ARE_YOU_SOURCE)),
|
||||
at.read(&format!("{TEST_HOW_ARE_YOU_SOURCE}.~2~")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -557,7 +557,7 @@ fn test_cp_numbered_if_existing_backup_existing() {
|
|||
#[test]
|
||||
fn test_cp_numbered_if_existing_backup_nil() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let existing_backup = &format!("{}.~1~", TEST_HOW_ARE_YOU_SOURCE);
|
||||
let existing_backup = &format!("{TEST_HOW_ARE_YOU_SOURCE}.~1~");
|
||||
|
||||
at.touch(existing_backup);
|
||||
ucmd.arg("--backup=nil")
|
||||
|
@ -569,7 +569,7 @@ fn test_cp_numbered_if_existing_backup_nil() {
|
|||
assert!(at.file_exists(TEST_HOW_ARE_YOU_SOURCE));
|
||||
assert!(at.file_exists(existing_backup));
|
||||
assert_eq!(
|
||||
at.read(&format!("{}.~2~", TEST_HOW_ARE_YOU_SOURCE)),
|
||||
at.read(&format!("{TEST_HOW_ARE_YOU_SOURCE}.~2~")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -586,7 +586,7 @@ fn test_cp_backup_simple() {
|
|||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
|
||||
assert_eq!(
|
||||
at.read(&format!("{}~", TEST_HOW_ARE_YOU_SOURCE)),
|
||||
at.read(&format!("{TEST_HOW_ARE_YOU_SOURCE}~")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -594,15 +594,14 @@ fn test_cp_backup_simple() {
|
|||
#[test]
|
||||
fn test_cp_backup_simple_protect_source() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let source = format!("{}~", TEST_HELLO_WORLD_SOURCE);
|
||||
let source = format!("{TEST_HELLO_WORLD_SOURCE}~");
|
||||
at.touch(&source);
|
||||
ucmd.arg("--backup=simple")
|
||||
.arg(&source)
|
||||
.arg(TEST_HELLO_WORLD_SOURCE)
|
||||
.fails()
|
||||
.stderr_only(format!(
|
||||
"cp: backing up '{}' might destroy source; '{}' not copied\n",
|
||||
TEST_HELLO_WORLD_SOURCE, source,
|
||||
"cp: backing up '{TEST_HELLO_WORLD_SOURCE}' might destroy source; '{source}' not copied\n",
|
||||
));
|
||||
|
||||
assert_eq!(at.read(TEST_HELLO_WORLD_SOURCE), "Hello, World!\n");
|
||||
|
@ -621,7 +620,7 @@ fn test_cp_backup_never() {
|
|||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
|
||||
assert_eq!(
|
||||
at.read(&format!("{}~", TEST_HOW_ARE_YOU_SOURCE)),
|
||||
at.read(&format!("{TEST_HOW_ARE_YOU_SOURCE}~")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -637,7 +636,7 @@ fn test_cp_backup_none() {
|
|||
.no_stderr();
|
||||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
|
||||
assert!(!at.file_exists(&format!("{}~", TEST_HOW_ARE_YOU_SOURCE)));
|
||||
assert!(!at.file_exists(&format!("{TEST_HOW_ARE_YOU_SOURCE}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -651,7 +650,7 @@ fn test_cp_backup_off() {
|
|||
.no_stderr();
|
||||
|
||||
assert_eq!(at.read(TEST_HOW_ARE_YOU_SOURCE), "Hello, World!\n");
|
||||
assert!(!at.file_exists(&format!("{}~", TEST_HOW_ARE_YOU_SOURCE)));
|
||||
assert!(!at.file_exists(&format!("{TEST_HOW_ARE_YOU_SOURCE}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -801,7 +800,7 @@ fn test_cp_strip_trailing_slashes() {
|
|||
|
||||
//using --strip-trailing-slashes option
|
||||
ucmd.arg("--strip-trailing-slashes")
|
||||
.arg(format!("{}/", TEST_HELLO_WORLD_SOURCE))
|
||||
.arg(format!("{TEST_HELLO_WORLD_SOURCE}/"))
|
||||
.arg(TEST_HELLO_WORLD_DEST)
|
||||
.succeeds();
|
||||
|
||||
|
@ -820,8 +819,7 @@ fn test_cp_parents() {
|
|||
|
||||
assert_eq!(
|
||||
at.read(&format!(
|
||||
"{}/{}",
|
||||
TEST_COPY_TO_FOLDER, TEST_COPY_FROM_FOLDER_FILE
|
||||
"{TEST_COPY_TO_FOLDER}/{TEST_COPY_FROM_FOLDER_FILE}"
|
||||
)),
|
||||
"Hello, World!\n"
|
||||
);
|
||||
|
@ -839,16 +837,12 @@ fn test_cp_parents_multiple_files() {
|
|||
|
||||
assert_eq!(
|
||||
at.read(&format!(
|
||||
"{}/{}",
|
||||
TEST_COPY_TO_FOLDER, TEST_COPY_FROM_FOLDER_FILE
|
||||
"{TEST_COPY_TO_FOLDER}/{TEST_COPY_FROM_FOLDER_FILE}"
|
||||
)),
|
||||
"Hello, World!\n"
|
||||
);
|
||||
assert_eq!(
|
||||
at.read(&format!(
|
||||
"{}/{}",
|
||||
TEST_COPY_TO_FOLDER, TEST_HOW_ARE_YOU_SOURCE
|
||||
)),
|
||||
at.read(&format!("{TEST_COPY_TO_FOLDER}/{TEST_HOW_ARE_YOU_SOURCE}")),
|
||||
"How are you?\n"
|
||||
);
|
||||
}
|
||||
|
@ -1350,7 +1344,7 @@ fn test_cp_no_preserve_timestamps() {
|
|||
let result = scene2.cmd("ls").arg("-al").arg(at.subdir).run();
|
||||
|
||||
println!("ls dest {}", result.stdout_str());
|
||||
println!("creation {:?} / {:?}", creation, creation2);
|
||||
println!("creation {creation:?} / {creation2:?}");
|
||||
|
||||
assert_ne!(creation, creation2);
|
||||
let res = creation.elapsed().unwrap() - creation2.elapsed().unwrap();
|
||||
|
|
|
@ -4,7 +4,7 @@ use glob::glob;
|
|||
/// Returns a string of numbers with the given range, each on a new line.
|
||||
/// The upper bound is not included.
|
||||
fn generate(from: u32, to: u32) -> String {
|
||||
(from..to).fold(String::new(), |acc, v| format!("{}{}\n", acc, v))
|
||||
(from..to).fold(String::new(), |acc, v| format!("{acc}{v}\n"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -31,13 +31,13 @@ fn test_date_rfc_3339() {
|
|||
for param in ["--rfc-3339", "--rfc-3"] {
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(format!("{}=ns", param))
|
||||
.arg(format!("{param}=ns"))
|
||||
.succeeds()
|
||||
.stdout_matches(&re);
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(format!("{}=seconds", param))
|
||||
.arg(format!("{param}=seconds"))
|
||||
.succeeds()
|
||||
.stdout_matches(&re);
|
||||
}
|
||||
|
@ -46,14 +46,14 @@ fn test_date_rfc_3339() {
|
|||
#[test]
|
||||
fn test_date_rfc_8601() {
|
||||
for param in ["--iso-8601", "--i"] {
|
||||
new_ucmd!().arg(format!("{}=ns", param)).succeeds();
|
||||
new_ucmd!().arg(format!("{param}=ns")).succeeds();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_date_rfc_8601_second() {
|
||||
for param in ["--iso-8601", "--i"] {
|
||||
new_ucmd!().arg(format!("{}=second", param)).succeeds();
|
||||
new_ucmd!().arg(format!("{param}=second")).succeeds();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -211,35 +211,35 @@ fn test_x_multiplier() {
|
|||
fn test_zero_multiplier_warning() {
|
||||
for arg in ["count", "seek", "skip"] {
|
||||
new_ucmd!()
|
||||
.args(&[format!("{}=0", arg).as_str(), "status=none"])
|
||||
.args(&[format!("{arg}=0").as_str(), "status=none"])
|
||||
.pipe_in("")
|
||||
.succeeds()
|
||||
.no_stdout()
|
||||
.no_stderr();
|
||||
|
||||
new_ucmd!()
|
||||
.args(&[format!("{}=00x1", arg).as_str(), "status=none"])
|
||||
.args(&[format!("{arg}=00x1").as_str(), "status=none"])
|
||||
.pipe_in("")
|
||||
.succeeds()
|
||||
.no_stdout()
|
||||
.no_stderr();
|
||||
|
||||
new_ucmd!()
|
||||
.args(&[format!("{}=0x1", arg).as_str(), "status=none"])
|
||||
.args(&[format!("{arg}=0x1").as_str(), "status=none"])
|
||||
.pipe_in("")
|
||||
.succeeds()
|
||||
.no_stdout()
|
||||
.stderr_contains("warning: '0x' is a zero multiplier; use '00x' if that is intended");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&[format!("{}=0x0x1", arg).as_str(), "status=none"])
|
||||
.args(&[format!("{arg}=0x0x1").as_str(), "status=none"])
|
||||
.pipe_in("")
|
||||
.succeeds()
|
||||
.no_stdout()
|
||||
.stderr_is("dd: warning: '0x' is a zero multiplier; use '00x' if that is intended\ndd: warning: '0x' is a zero multiplier; use '00x' if that is intended\n");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&[format!("{}=1x0x1", arg).as_str(), "status=none"])
|
||||
.args(&[format!("{arg}=1x0x1").as_str(), "status=none"])
|
||||
.pipe_in("")
|
||||
.succeeds()
|
||||
.no_stdout()
|
||||
|
@ -496,7 +496,7 @@ fn test_ascii_10k_to_stdout() {
|
|||
#[test]
|
||||
fn test_zeros_to_file() {
|
||||
let tname = "zero-256k";
|
||||
let test_fn = format!("{}.txt", tname);
|
||||
let test_fn = format!("{tname}.txt");
|
||||
let tmp_fn = format!("TESTFILE-{}.tmp", &tname);
|
||||
assert_fixture_exists!(test_fn);
|
||||
|
||||
|
@ -516,7 +516,7 @@ fn test_zeros_to_file() {
|
|||
#[test]
|
||||
fn test_to_file_with_ibs_obs() {
|
||||
let tname = "zero-256k";
|
||||
let test_fn = format!("{}.txt", tname);
|
||||
let test_fn = format!("{tname}.txt");
|
||||
let tmp_fn = format!("TESTFILE-{}.tmp", &tname);
|
||||
assert_fixture_exists!(test_fn);
|
||||
|
||||
|
@ -608,7 +608,7 @@ fn test_self_transfer() {
|
|||
#[test]
|
||||
fn test_unicode_filenames() {
|
||||
let tname = "😎💚🦊";
|
||||
let test_fn = format!("{}.txt", tname);
|
||||
let test_fn = format!("{tname}.txt");
|
||||
let tmp_fn = format!("TESTFILE-{}.tmp", &tname);
|
||||
assert_fixture_exists!(test_fn);
|
||||
|
||||
|
@ -1284,12 +1284,12 @@ fn test_invalid_number_arg_gnu_compatibility() {
|
|||
|
||||
for command in commands {
|
||||
new_ucmd!()
|
||||
.args(&[format!("{}=", command)])
|
||||
.args(&[format!("{command}=")])
|
||||
.fails()
|
||||
.stderr_is("dd: invalid number: ‘’\n");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&[format!("{}=29d", command)])
|
||||
.args(&[format!("{command}=29d")])
|
||||
.fails()
|
||||
.stderr_is("dd: invalid number: ‘29d’\n");
|
||||
}
|
||||
|
@ -1301,12 +1301,12 @@ fn test_invalid_flag_arg_gnu_compatibility() {
|
|||
|
||||
for command in commands {
|
||||
new_ucmd!()
|
||||
.args(&[format!("{}=", command)])
|
||||
.args(&[format!("{command}=")])
|
||||
.fails()
|
||||
.usage_error("invalid input flag: ‘’");
|
||||
|
||||
new_ucmd!()
|
||||
.args(&[format!("{}=29d", command)])
|
||||
.args(&[format!("{command}=29d")])
|
||||
.fails()
|
||||
.usage_error("invalid input flag: ‘29d’");
|
||||
}
|
||||
|
|
|
@ -519,7 +519,7 @@ fn test_default_block_size_in_posix_portability_mode() {
|
|||
fn test_block_size_1024() {
|
||||
fn get_header(block_size: u64) -> String {
|
||||
let output = new_ucmd!()
|
||||
.args(&["-B", &format!("{}", block_size), "--output=size"])
|
||||
.args(&["-B", &format!("{block_size}"), "--output=size"])
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
output.lines().next().unwrap().trim().to_string()
|
||||
|
@ -693,9 +693,9 @@ fn test_ignore_block_size_from_env_in_posix_portability_mode() {
|
|||
fn test_too_large_block_size() {
|
||||
fn run_command(size: &str) {
|
||||
new_ucmd!()
|
||||
.arg(format!("--block-size={}", size))
|
||||
.arg(format!("--block-size={size}"))
|
||||
.fails()
|
||||
.stderr_contains(format!("--block-size argument '{}' too large", size));
|
||||
.stderr_contains(format!("--block-size argument '{size}' too large"));
|
||||
}
|
||||
|
||||
let too_large_sizes = vec!["1Y", "1Z"];
|
||||
|
|
|
@ -210,14 +210,14 @@ fn test_helper(file_name: &str, term: &str) {
|
|||
new_ucmd!()
|
||||
.env("TERM", term)
|
||||
.arg("-c")
|
||||
.arg(format!("{}.txt", file_name))
|
||||
.arg(format!("{file_name}.txt"))
|
||||
.run()
|
||||
.stdout_is_fixture(format!("{}.csh.expected", file_name));
|
||||
.stdout_is_fixture(format!("{file_name}.csh.expected"));
|
||||
|
||||
new_ucmd!()
|
||||
.env("TERM", term)
|
||||
.arg("-b")
|
||||
.arg(format!("{}.txt", file_name))
|
||||
.arg(format!("{file_name}.txt"))
|
||||
.run()
|
||||
.stdout_is_fixture(format!("{}.sh.expected", file_name));
|
||||
.stdout_is_fixture(format!("{file_name}.sh.expected"));
|
||||
}
|
||||
|
|
|
@ -95,24 +95,24 @@ fn test_du_invalid_size() {
|
|||
let ts = TestScenario::new(util_name!());
|
||||
for s in args {
|
||||
ts.ucmd()
|
||||
.arg(format!("--{}=1fb4t", s))
|
||||
.arg(format!("--{s}=1fb4t"))
|
||||
.arg("/tmp")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_only(format!("du: invalid suffix in --{} argument '1fb4t'\n", s));
|
||||
.stderr_only(format!("du: invalid suffix in --{s} argument '1fb4t'\n"));
|
||||
ts.ucmd()
|
||||
.arg(format!("--{}=x", s))
|
||||
.arg(format!("--{s}=x"))
|
||||
.arg("/tmp")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_only(format!("du: invalid --{} argument 'x'\n", s));
|
||||
.stderr_only(format!("du: invalid --{s} argument 'x'\n"));
|
||||
#[cfg(not(target_pointer_width = "128"))]
|
||||
ts.ucmd()
|
||||
.arg(format!("--{}=1Y", s))
|
||||
.arg(format!("--{s}=1Y"))
|
||||
.arg("/tmp")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_only(format!("du: --{} argument '1Y' too large\n", s));
|
||||
.stderr_only(format!("du: --{s} argument '1Y' too large\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -511,13 +511,13 @@ fn test_du_threshold() {
|
|||
let threshold = if cfg!(windows) { "7K" } else { "10K" };
|
||||
|
||||
ts.ucmd()
|
||||
.arg(format!("--threshold={}", threshold))
|
||||
.arg(format!("--threshold={threshold}"))
|
||||
.succeeds()
|
||||
.stdout_contains("links")
|
||||
.stdout_does_not_contain("deeper_dir");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(format!("--threshold=-{}", threshold))
|
||||
.arg(format!("--threshold=-{threshold}"))
|
||||
.succeeds()
|
||||
.stdout_does_not_contain("links")
|
||||
.stdout_contains("deeper_dir");
|
||||
|
|
|
@ -176,7 +176,7 @@ fn test_disable_escapes() {
|
|||
.arg("-E")
|
||||
.arg(input_str)
|
||||
.succeeds()
|
||||
.stdout_only(format!("{}\n", input_str));
|
||||
.stdout_only(format!("{input_str}\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -41,7 +41,7 @@ fn test_parallel() {
|
|||
let n_integers = 100_000;
|
||||
let mut input_string = String::new();
|
||||
for i in 0..=n_integers {
|
||||
input_string.push_str(&(format!("{} ", i))[..]);
|
||||
input_string.push_str(&(format!("{i} "))[..]);
|
||||
}
|
||||
|
||||
let tmp_dir = TempDir::new().unwrap();
|
||||
|
@ -87,10 +87,10 @@ fn test_first_1000_integers() {
|
|||
let n_integers = 1000;
|
||||
let mut input_string = String::new();
|
||||
for i in 0..=n_integers {
|
||||
input_string.push_str(&(format!("{} ", i))[..]);
|
||||
input_string.push_str(&(format!("{i} "))[..]);
|
||||
}
|
||||
|
||||
println!("STDIN='{}'", input_string);
|
||||
println!("STDIN='{input_string}'");
|
||||
let result = new_ucmd!().pipe_in(input_string.as_bytes()).succeeds();
|
||||
|
||||
// `seq 0 1000 | factor | sha1sum` => "c734327bd18b90fca5762f671672b5eda19f7dca"
|
||||
|
@ -126,7 +126,7 @@ fn test_random() {
|
|||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs();
|
||||
println!("rng_seed={:?}", rng_seed);
|
||||
println!("rng_seed={rng_seed:?}");
|
||||
let mut rng = SmallRng::seed_from_u64(rng_seed);
|
||||
|
||||
let mut rand_gt = move |min: u64| {
|
||||
|
@ -162,11 +162,11 @@ fn test_random() {
|
|||
let mut output_string = String::new();
|
||||
for _ in 0..NUM_TESTS {
|
||||
let (product, factors) = rand_gt(1 << 63);
|
||||
input_string.push_str(&(format!("{} ", product))[..]);
|
||||
input_string.push_str(&(format!("{product} "))[..]);
|
||||
|
||||
output_string.push_str(&(format!("{}:", product))[..]);
|
||||
output_string.push_str(&(format!("{product}:"))[..]);
|
||||
for factor in factors {
|
||||
output_string.push_str(&(format!(" {}", factor))[..]);
|
||||
output_string.push_str(&(format!(" {factor}"))[..]);
|
||||
}
|
||||
output_string.push('\n');
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ fn test_random_big() {
|
|||
.duration_since(SystemTime::UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs();
|
||||
println!("rng_seed={:?}", rng_seed);
|
||||
println!("rng_seed={rng_seed:?}");
|
||||
let mut rng = SmallRng::seed_from_u64(rng_seed);
|
||||
|
||||
let bit_range_1 = Uniform::new(14_usize, 51);
|
||||
|
@ -244,11 +244,11 @@ fn test_random_big() {
|
|||
let mut output_string = String::new();
|
||||
for _ in 0..NUM_TESTS {
|
||||
let (product, factors) = rand_64();
|
||||
input_string.push_str(&(format!("{} ", product))[..]);
|
||||
input_string.push_str(&(format!("{product} "))[..]);
|
||||
|
||||
output_string.push_str(&(format!("{}:", product))[..]);
|
||||
output_string.push_str(&(format!("{product}:"))[..]);
|
||||
for factor in factors {
|
||||
output_string.push_str(&(format!(" {}", factor))[..]);
|
||||
output_string.push_str(&(format!(" {factor}"))[..]);
|
||||
}
|
||||
output_string.push('\n');
|
||||
}
|
||||
|
@ -261,8 +261,8 @@ fn test_big_primes() {
|
|||
let mut input_string = String::new();
|
||||
let mut output_string = String::new();
|
||||
for prime in PRIMES64 {
|
||||
input_string.push_str(&(format!("{} ", prime))[..]);
|
||||
output_string.push_str(&(format!("{0}: {0}\n", prime))[..]);
|
||||
input_string.push_str(&(format!("{prime} "))[..]);
|
||||
output_string.push_str(&(format!("{prime}: {prime}\n"))[..]);
|
||||
}
|
||||
|
||||
run(input_string.as_bytes(), output_string.as_bytes());
|
||||
|
|
|
@ -28,8 +28,8 @@ fn test_install_basic() {
|
|||
|
||||
assert!(at.file_exists(file1));
|
||||
assert!(at.file_exists(file2));
|
||||
assert!(at.file_exists(&format!("{}/{}", dir, file1)));
|
||||
assert!(at.file_exists(&format!("{}/{}", dir, file2)));
|
||||
assert!(at.file_exists(&format!("{dir}/{file1}")));
|
||||
assert!(at.file_exists(&format!("{dir}/{file2}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -76,7 +76,7 @@ fn test_install_unimplemented_arg() {
|
|||
.fails()
|
||||
.stderr_contains("Unimplemented");
|
||||
|
||||
assert!(!at.file_exists(&format!("{}/{}", dir, file)));
|
||||
assert!(!at.file_exists(&format!("{dir}/{file}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -181,7 +181,7 @@ fn test_install_mode_numeric() {
|
|||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
let dest_file = &format!("{}/{}", dir, file);
|
||||
let dest_file = &format!("{dir}/{file}");
|
||||
assert!(at.file_exists(file));
|
||||
assert!(at.file_exists(dest_file));
|
||||
let permissions = at.metadata(dest_file).permissions();
|
||||
|
@ -192,7 +192,7 @@ fn test_install_mode_numeric() {
|
|||
|
||||
scene.ucmd().arg(mode_arg).arg(file).arg(dir2).succeeds();
|
||||
|
||||
let dest_file = &format!("{}/{}", dir2, file);
|
||||
let dest_file = &format!("{dir2}/{file}");
|
||||
assert!(at.file_exists(file));
|
||||
assert!(at.file_exists(dest_file));
|
||||
let permissions = at.metadata(dest_file).permissions();
|
||||
|
@ -210,7 +210,7 @@ fn test_install_mode_symbolic() {
|
|||
at.mkdir(dir);
|
||||
ucmd.arg(file).arg(dir).arg(mode_arg).succeeds().no_stderr();
|
||||
|
||||
let dest_file = &format!("{}/{}", dir, file);
|
||||
let dest_file = &format!("{dir}/{file}");
|
||||
assert!(at.file_exists(file));
|
||||
assert!(at.file_exists(dest_file));
|
||||
let permissions = at.metadata(dest_file).permissions();
|
||||
|
@ -232,7 +232,7 @@ fn test_install_mode_failing() {
|
|||
.fails()
|
||||
.stderr_contains("Invalid mode string: invalid digit found in string");
|
||||
|
||||
let dest_file = &format!("{}/{}", dir, file);
|
||||
let dest_file = &format!("{dir}/{file}");
|
||||
assert!(at.file_exists(file));
|
||||
assert!(!at.file_exists(dest_file));
|
||||
}
|
||||
|
@ -278,12 +278,12 @@ fn test_install_target_new_file() {
|
|||
at.touch(file);
|
||||
at.mkdir(dir);
|
||||
ucmd.arg(file)
|
||||
.arg(format!("{}/{}", dir, file))
|
||||
.arg(format!("{dir}/{file}"))
|
||||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
assert!(at.file_exists(file));
|
||||
assert!(at.file_exists(&format!("{}/{}", dir, file)));
|
||||
assert!(at.file_exists(&format!("{dir}/{file}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -299,7 +299,7 @@ fn test_install_target_new_file_with_group() {
|
|||
.arg(file)
|
||||
.arg("--group")
|
||||
.arg(gid.to_string())
|
||||
.arg(format!("{}/{}", dir, file))
|
||||
.arg(format!("{dir}/{file}"))
|
||||
.run();
|
||||
|
||||
if is_ci() && result.stderr_str().contains("no such group:") {
|
||||
|
@ -310,7 +310,7 @@ fn test_install_target_new_file_with_group() {
|
|||
|
||||
result.success();
|
||||
assert!(at.file_exists(file));
|
||||
assert!(at.file_exists(&format!("{}/{}", dir, file)));
|
||||
assert!(at.file_exists(&format!("{dir}/{file}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -326,7 +326,7 @@ fn test_install_target_new_file_with_owner() {
|
|||
.arg(file)
|
||||
.arg("--owner")
|
||||
.arg(uid.to_string())
|
||||
.arg(format!("{}/{}", dir, file))
|
||||
.arg(format!("{dir}/{file}"))
|
||||
.run();
|
||||
|
||||
if is_ci() && result.stderr_str().contains("no such user:") {
|
||||
|
@ -337,7 +337,7 @@ fn test_install_target_new_file_with_owner() {
|
|||
|
||||
result.success();
|
||||
assert!(at.file_exists(file));
|
||||
assert!(at.file_exists(&format!("{}/{}", dir, file)));
|
||||
assert!(at.file_exists(&format!("{dir}/{file}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -350,7 +350,7 @@ fn test_install_target_new_file_failing_nonexistent_parent() {
|
|||
at.touch(file1);
|
||||
|
||||
ucmd.arg(file1)
|
||||
.arg(format!("{}/{}", dir, file2))
|
||||
.arg(format!("{dir}/{file2}"))
|
||||
.fails()
|
||||
.stderr_contains("No such file or directory");
|
||||
}
|
||||
|
@ -416,13 +416,13 @@ fn test_install_nested_paths_copy_file() {
|
|||
|
||||
at.mkdir(dir1);
|
||||
at.mkdir(dir2);
|
||||
at.touch(&format!("{}/{}", dir1, file1));
|
||||
at.touch(&format!("{dir1}/{file1}"));
|
||||
|
||||
ucmd.arg(format!("{}/{}", dir1, file1))
|
||||
ucmd.arg(format!("{dir1}/{file1}"))
|
||||
.arg(dir2)
|
||||
.succeeds()
|
||||
.no_stderr();
|
||||
assert!(at.file_exists(&format!("{}/{}", dir2, file1)));
|
||||
assert!(at.file_exists(&format!("{dir2}/{file1}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -456,7 +456,7 @@ fn test_install_failing_omitting_directory() {
|
|||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains("omitting directory");
|
||||
assert!(at.file_exists(&format!("{}/{}", dir3, file1)));
|
||||
assert!(at.file_exists(&format!("{dir3}/{file1}")));
|
||||
|
||||
// install also fails, when only one source param is given
|
||||
scene
|
||||
|
@ -826,14 +826,14 @@ fn test_install_dir() {
|
|||
at.mkdir(dir);
|
||||
ucmd.arg(file1)
|
||||
.arg(file2)
|
||||
.arg(&format!("--target-directory={}", dir))
|
||||
.arg(&format!("--target-directory={dir}"))
|
||||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
assert!(at.file_exists(file1));
|
||||
assert!(at.file_exists(file2));
|
||||
assert!(at.file_exists(&format!("{}/{}", dir, file1)));
|
||||
assert!(at.file_exists(&format!("{}/{}", dir, file2)));
|
||||
assert!(at.file_exists(&format!("{dir}/{file1}")));
|
||||
assert!(at.file_exists(&format!("{dir}/{file2}")));
|
||||
}
|
||||
//
|
||||
// test backup functionality
|
||||
|
@ -857,7 +857,7 @@ fn test_install_backup_short_no_args_files() {
|
|||
|
||||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -867,7 +867,7 @@ fn test_install_backup_short_no_args_file_to_dir() {
|
|||
|
||||
let file = "test_install_simple_backup_file_a";
|
||||
let dest_dir = "test_install_dest/";
|
||||
let expect = format!("{}{}", dest_dir, file);
|
||||
let expect = format!("{dest_dir}{file}");
|
||||
|
||||
at.touch(file);
|
||||
at.mkdir(dest_dir);
|
||||
|
@ -882,7 +882,7 @@ fn test_install_backup_short_no_args_file_to_dir() {
|
|||
|
||||
assert!(at.file_exists(file));
|
||||
assert!(at.file_exists(&expect));
|
||||
assert!(at.file_exists(&format!("{}~", expect)));
|
||||
assert!(at.file_exists(&format!("{expect}~")));
|
||||
}
|
||||
|
||||
// Long --backup option is tested separately as it requires a slightly different
|
||||
|
@ -907,7 +907,7 @@ fn test_install_backup_long_no_args_files() {
|
|||
|
||||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -917,7 +917,7 @@ fn test_install_backup_long_no_args_file_to_dir() {
|
|||
|
||||
let file = "test_install_simple_backup_file_a";
|
||||
let dest_dir = "test_install_dest/";
|
||||
let expect = format!("{}{}", dest_dir, file);
|
||||
let expect = format!("{dest_dir}{file}");
|
||||
|
||||
at.touch(file);
|
||||
at.mkdir(dest_dir);
|
||||
|
@ -932,7 +932,7 @@ fn test_install_backup_long_no_args_file_to_dir() {
|
|||
|
||||
assert!(at.file_exists(file));
|
||||
assert!(at.file_exists(&expect));
|
||||
assert!(at.file_exists(&format!("{}~", expect)));
|
||||
assert!(at.file_exists(&format!("{expect}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -949,7 +949,7 @@ fn test_install_backup_short_custom_suffix() {
|
|||
scene
|
||||
.ucmd()
|
||||
.arg("-b")
|
||||
.arg(format!("--suffix={}", suffix))
|
||||
.arg(format!("--suffix={suffix}"))
|
||||
.arg(file_a)
|
||||
.arg(file_b)
|
||||
.succeeds()
|
||||
|
@ -957,7 +957,7 @@ fn test_install_backup_short_custom_suffix() {
|
|||
|
||||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}{}", file_b, suffix)));
|
||||
assert!(at.file_exists(&format!("{file_b}{suffix}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -974,7 +974,7 @@ fn test_install_backup_short_custom_suffix_hyphen_value() {
|
|||
scene
|
||||
.ucmd()
|
||||
.arg("-b")
|
||||
.arg(format!("--suffix={}", suffix))
|
||||
.arg(format!("--suffix={suffix}"))
|
||||
.arg(file_a)
|
||||
.arg(file_b)
|
||||
.succeeds()
|
||||
|
@ -982,7 +982,7 @@ fn test_install_backup_short_custom_suffix_hyphen_value() {
|
|||
|
||||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}{}", file_b, suffix)));
|
||||
assert!(at.file_exists(&format!("{file_b}{suffix}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1007,7 +1007,7 @@ fn test_install_backup_custom_suffix_via_env() {
|
|||
|
||||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}{}", file_b, suffix)));
|
||||
assert!(at.file_exists(&format!("{file_b}{suffix}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1030,7 +1030,7 @@ fn test_install_backup_numbered_with_t() {
|
|||
|
||||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}.~1~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}.~1~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1053,7 +1053,7 @@ fn test_install_backup_numbered_with_numbered() {
|
|||
|
||||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}.~1~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}.~1~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1076,7 +1076,7 @@ fn test_install_backup_existing() {
|
|||
|
||||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1099,7 +1099,7 @@ fn test_install_backup_nil() {
|
|||
|
||||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1125,7 +1125,7 @@ fn test_install_backup_numbered_if_existing_backup_existing() {
|
|||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(file_b_backup));
|
||||
assert!(at.file_exists(&format!("{}.~2~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}.~2~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1151,7 +1151,7 @@ fn test_install_backup_numbered_if_existing_backup_nil() {
|
|||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(file_b_backup));
|
||||
assert!(at.file_exists(&format!("{}.~2~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}.~2~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1174,7 +1174,7 @@ fn test_install_backup_simple() {
|
|||
|
||||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1197,7 +1197,7 @@ fn test_install_backup_never() {
|
|||
|
||||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1220,7 +1220,7 @@ fn test_install_backup_none() {
|
|||
|
||||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(!at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(!at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1243,7 +1243,7 @@ fn test_install_backup_off() {
|
|||
|
||||
assert!(at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(!at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(!at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1262,7 +1262,7 @@ fn test_install_missing_arguments() {
|
|||
scene
|
||||
.ucmd()
|
||||
.arg("-D")
|
||||
.arg(format!("-t {}", no_target_dir))
|
||||
.arg(format!("-t {no_target_dir}"))
|
||||
.fails()
|
||||
.usage_error("missing file operand");
|
||||
assert!(!at.dir_exists(no_target_dir));
|
||||
|
@ -1280,17 +1280,19 @@ fn test_install_missing_destination() {
|
|||
at.mkdir(dir_1);
|
||||
|
||||
// will fail and also print some info on correct usage
|
||||
scene.ucmd().arg(file_1).fails().usage_error(format!(
|
||||
"missing destination file operand after '{}'",
|
||||
file_1
|
||||
));
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(file_1)
|
||||
.fails()
|
||||
.usage_error(format!("missing destination file operand after '{file_1}'"));
|
||||
|
||||
// GNU's install will check for correct num of arguments and then fail
|
||||
// and it does not recognize, that the source is not a file but a directory.
|
||||
scene.ucmd().arg(dir_1).fails().usage_error(format!(
|
||||
"missing destination file operand after '{}'",
|
||||
dir_1
|
||||
));
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(dir_1)
|
||||
.fails()
|
||||
.usage_error(format!("missing destination file operand after '{dir_1}'"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -1378,7 +1380,7 @@ fn test_install_compare_option() {
|
|||
.ucmd()
|
||||
.args(&["-Cv", first, second])
|
||||
.succeeds()
|
||||
.stdout_contains(format!("'{}' -> '{}'", first, second));
|
||||
.stdout_contains(format!("'{first}' -> '{second}'"));
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-Cv", first, second])
|
||||
|
@ -1388,12 +1390,12 @@ fn test_install_compare_option() {
|
|||
.ucmd()
|
||||
.args(&["-Cv", "-m0644", first, second])
|
||||
.succeeds()
|
||||
.stdout_contains(format!("removed '{}'\n'{}' -> '{}'", second, first, second));
|
||||
.stdout_contains(format!("removed '{second}'\n'{first}' -> '{second}'"));
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-Cv", first, second])
|
||||
.succeeds()
|
||||
.stdout_contains(format!("removed '{}'\n'{}' -> '{}'", second, first, second));
|
||||
.stdout_contains(format!("removed '{second}'\n'{first}' -> '{second}'"));
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-C", "--preserve-timestamps", first, second])
|
||||
|
|
|
@ -153,7 +153,7 @@ fn test_symlink_simple_backup() {
|
|||
assert!(at.is_symlink(link));
|
||||
assert_eq!(at.resolve_link(link), file);
|
||||
|
||||
let backup = &format!("{}~", link);
|
||||
let backup = &format!("{link}~");
|
||||
assert!(at.is_symlink(backup));
|
||||
assert_eq!(at.resolve_link(backup), file);
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ fn test_symlink_custom_backup_suffix() {
|
|||
assert!(at.is_symlink(link));
|
||||
assert_eq!(at.resolve_link(link), file);
|
||||
|
||||
let arg = &format!("--suffix={}", suffix);
|
||||
let arg = &format!("--suffix={suffix}");
|
||||
ucmd.args(&["-b", arg, "-s", file, link])
|
||||
.succeeds()
|
||||
.no_stderr();
|
||||
|
@ -180,7 +180,7 @@ fn test_symlink_custom_backup_suffix() {
|
|||
assert!(at.is_symlink(link));
|
||||
assert_eq!(at.resolve_link(link), file);
|
||||
|
||||
let backup = &format!("{}{}", link, suffix);
|
||||
let backup = &format!("{link}{suffix}");
|
||||
assert!(at.is_symlink(backup));
|
||||
assert_eq!(at.resolve_link(backup), file);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ fn test_symlink_custom_backup_suffix_hyphen_value() {
|
|||
assert!(at.is_symlink(link));
|
||||
assert_eq!(at.resolve_link(link), file);
|
||||
|
||||
let arg = &format!("--suffix={}", suffix);
|
||||
let arg = &format!("--suffix={suffix}");
|
||||
ucmd.args(&["-b", arg, "-s", file, link])
|
||||
.succeeds()
|
||||
.no_stderr();
|
||||
|
@ -207,7 +207,7 @@ fn test_symlink_custom_backup_suffix_hyphen_value() {
|
|||
assert!(at.is_symlink(link));
|
||||
assert_eq!(at.resolve_link(link), file);
|
||||
|
||||
let backup = &format!("{}{}", link, suffix);
|
||||
let backup = &format!("{link}{suffix}");
|
||||
assert!(at.is_symlink(backup));
|
||||
assert_eq!(at.resolve_link(backup), file);
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ fn test_symlink_backup_numbering() {
|
|||
assert!(at.is_symlink(link));
|
||||
assert_eq!(at.resolve_link(link), file);
|
||||
|
||||
let backup = &format!("{}.~1~", link);
|
||||
let backup = &format!("{link}.~1~");
|
||||
assert!(at.is_symlink(backup));
|
||||
assert_eq!(at.resolve_link(backup), file);
|
||||
}
|
||||
|
@ -285,11 +285,11 @@ fn test_symlink_target_dir() {
|
|||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
let file_a_link = &format!("{}/{}", dir, file_a);
|
||||
let file_a_link = &format!("{dir}/{file_a}");
|
||||
assert!(at.is_symlink(file_a_link));
|
||||
assert_eq!(at.resolve_link(file_a_link), file_a);
|
||||
|
||||
let file_b_link = &format!("{}/{}", dir, file_b);
|
||||
let file_b_link = &format!("{dir}/{file_b}");
|
||||
assert!(at.is_symlink(file_b_link));
|
||||
assert_eq!(at.resolve_link(file_b_link), file_b);
|
||||
}
|
||||
|
@ -301,8 +301,8 @@ fn test_symlink_target_dir_from_dir() {
|
|||
let from_dir = "test_ln_target_dir_from_dir";
|
||||
let filename_a = "test_ln_target_dir_file_a";
|
||||
let filename_b = "test_ln_target_dir_file_b";
|
||||
let file_a = &format!("{}/{}", from_dir, filename_a);
|
||||
let file_b = &format!("{}/{}", from_dir, filename_b);
|
||||
let file_a = &format!("{from_dir}/{filename_a}");
|
||||
let file_b = &format!("{from_dir}/{filename_b}");
|
||||
|
||||
at.mkdir(from_dir);
|
||||
at.touch(file_a);
|
||||
|
@ -313,11 +313,11 @@ fn test_symlink_target_dir_from_dir() {
|
|||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
let file_a_link = &format!("{}/{}", dir, filename_a);
|
||||
let file_a_link = &format!("{dir}/{filename_a}");
|
||||
assert!(at.is_symlink(file_a_link));
|
||||
assert_eq!(&at.resolve_link(file_a_link), file_a);
|
||||
|
||||
let file_b_link = &format!("{}/{}", dir, filename_b);
|
||||
let file_b_link = &format!("{dir}/{filename_b}");
|
||||
assert!(at.is_symlink(file_b_link));
|
||||
assert_eq!(&at.resolve_link(file_b_link), file_b);
|
||||
}
|
||||
|
@ -367,7 +367,7 @@ fn test_symlink_verbose() {
|
|||
.ucmd()
|
||||
.args(&["-s", "-v", file_a, file_b])
|
||||
.succeeds()
|
||||
.stdout_only(format!("'{}' -> '{}'\n", file_b, file_a));
|
||||
.stdout_only(format!("'{file_b}' -> '{file_a}'\n"));
|
||||
|
||||
at.touch(file_b);
|
||||
|
||||
|
@ -375,10 +375,7 @@ fn test_symlink_verbose() {
|
|||
.ucmd()
|
||||
.args(&["-s", "-v", "-b", file_a, file_b])
|
||||
.succeeds()
|
||||
.stdout_only(format!(
|
||||
"'{}' -> '{}' (backup: '{}~')\n",
|
||||
file_b, file_a, file_b
|
||||
));
|
||||
.stdout_only(format!("'{file_b}' -> '{file_a}' (backup: '{file_b}~')\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -421,7 +418,7 @@ fn test_symlink_to_dir_2args() {
|
|||
let filename = "test_symlink_to_dir_2args_file";
|
||||
let from_file = &format!("{}/{}", at.as_string(), filename);
|
||||
let to_dir = "test_symlink_to_dir_2args_to_dir";
|
||||
let to_file = &format!("{}/{}", to_dir, filename);
|
||||
let to_file = &format!("{to_dir}/{filename}");
|
||||
|
||||
at.mkdir(to_dir);
|
||||
at.touch(from_file);
|
||||
|
@ -441,8 +438,7 @@ fn test_symlink_missing_destination() {
|
|||
at.touch(file);
|
||||
|
||||
ucmd.args(&["-s", "-T", file]).fails().stderr_is(format!(
|
||||
"ln: missing destination file operand after '{}'\n",
|
||||
file
|
||||
"ln: missing destination file operand after '{file}'\n"
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -475,7 +471,7 @@ fn test_symlink_relative_path() {
|
|||
// Thanks to -r, all the ../ should be resolved to a single file
|
||||
ucmd.args(&["-r", "-s", "-v", &p.to_string_lossy(), link])
|
||||
.succeeds()
|
||||
.stdout_only(format!("'{}' -> '{}'\n", link, file_a));
|
||||
.stdout_only(format!("'{link}' -> '{file_a}'\n"));
|
||||
assert!(at.is_symlink(link));
|
||||
assert_eq!(at.resolve_link(link), file_a);
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ fn test_normal() {
|
|||
println!("env::var(CI).is_ok() = {}", env::var("CI").is_ok());
|
||||
|
||||
for (key, value) in env::vars() {
|
||||
println!("{}: {}", key, value);
|
||||
println!("{key}: {value}");
|
||||
}
|
||||
if (is_ci() || uucore::os::is_wsl_1()) && result.stderr_str().contains("no login name") {
|
||||
// ToDO: investigate WSL failure
|
||||
|
|
|
@ -435,44 +435,43 @@ fn test_ls_io_errors() {
|
|||
|
||||
// on the mac and in certain Linux containers bad fds are typed as dirs,
|
||||
// however sometimes bad fds are typed as links and directory entry on links won't fail
|
||||
if PathBuf::from(format!("/dev/fd/{fd}", fd = fd2)).is_dir() {
|
||||
if PathBuf::from(format!("/dev/fd/{fd2}")).is_dir() {
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-alR")
|
||||
.arg(format!("/dev/fd/{fd}", fd = fd2))
|
||||
.arg(format!("/dev/fd/{fd2}"))
|
||||
.fails()
|
||||
.stderr_contains(format!(
|
||||
"cannot open directory '/dev/fd/{fd}': Bad file descriptor",
|
||||
fd = fd2
|
||||
"cannot open directory '/dev/fd/{fd2}': Bad file descriptor"
|
||||
))
|
||||
.stdout_does_not_contain(format!("{fd}:\n", fd = fd2));
|
||||
.stdout_does_not_contain(format!("{fd2}:\n"));
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-RiL")
|
||||
.arg(format!("/dev/fd/{fd}", fd = fd2))
|
||||
.arg(format!("/dev/fd/{fd2}"))
|
||||
.fails()
|
||||
.stderr_contains(format!("cannot open directory '/dev/fd/{fd}': Bad file descriptor", fd = fd2))
|
||||
.stderr_contains(format!("cannot open directory '/dev/fd/{fd2}': Bad file descriptor"))
|
||||
// don't double print bad fd errors
|
||||
.stderr_does_not_contain(format!("ls: cannot open directory '/dev/fd/{fd}': Bad file descriptor\nls: cannot open directory '/dev/fd/{fd}': Bad file descriptor", fd = fd2));
|
||||
.stderr_does_not_contain(format!("ls: cannot open directory '/dev/fd/{fd2}': Bad file descriptor\nls: cannot open directory '/dev/fd/{fd2}': Bad file descriptor"));
|
||||
} else {
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-alR")
|
||||
.arg(format!("/dev/fd/{fd}", fd = fd2))
|
||||
.arg(format!("/dev/fd/{fd2}"))
|
||||
.succeeds();
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-RiL")
|
||||
.arg(format!("/dev/fd/{fd}", fd = fd2))
|
||||
.arg(format!("/dev/fd/{fd2}"))
|
||||
.succeeds();
|
||||
}
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
.arg("-alL")
|
||||
.arg(format!("/dev/fd/{fd}", fd = fd2))
|
||||
.arg(format!("/dev/fd/{fd2}"))
|
||||
.succeeds();
|
||||
|
||||
let _ = close(fd2);
|
||||
|
@ -1932,10 +1931,7 @@ fn test_ls_color() {
|
|||
.arg("-w=15")
|
||||
.arg("-C")
|
||||
.succeeds()
|
||||
.stdout_only(format!(
|
||||
"{} test-color\nb {}\n",
|
||||
a_with_colors, z_with_colors
|
||||
));
|
||||
.stdout_only(format!("{a_with_colors} test-color\nb {z_with_colors}\n"));
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
@ -2041,7 +2037,7 @@ fn test_ls_indicator_style() {
|
|||
// Verify that classify and file-type both contain indicators for symlinks.
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(format!("--indicator-style={}", opt))
|
||||
.arg(format!("--indicator-style={opt}"))
|
||||
.succeeds()
|
||||
.stdout_contains("@")
|
||||
.stdout_contains("|");
|
||||
|
@ -2091,7 +2087,7 @@ fn test_ls_indicator_style() {
|
|||
// Verify that classify and file-type both contain indicators for symlinks.
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(format!("--indicator-style={}", opt))
|
||||
.arg(format!("--indicator-style={opt}"))
|
||||
.succeeds()
|
||||
.stdout_contains("/");
|
||||
}
|
||||
|
@ -2108,7 +2104,7 @@ fn test_ls_indicator_style() {
|
|||
// Verify that classify and file-type both contain indicators for symlinks.
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(format!("--indicator-style={}", opt))
|
||||
.arg(format!("--indicator-style={opt}"))
|
||||
.succeeds()
|
||||
.stdout_contains("@");
|
||||
}
|
||||
|
@ -2389,7 +2385,7 @@ fn test_ls_quoting_style() {
|
|||
.arg(arg)
|
||||
.arg("one\ntwo")
|
||||
.succeeds()
|
||||
.stdout_only(format!("{}\n", correct));
|
||||
.stdout_only(format!("{correct}\n"));
|
||||
}
|
||||
|
||||
for (arg, correct) in [
|
||||
|
@ -2405,7 +2401,7 @@ fn test_ls_quoting_style() {
|
|||
.arg("--show-control-chars")
|
||||
.arg("one\ntwo")
|
||||
.succeeds()
|
||||
.stdout_only(format!("{}\n", correct));
|
||||
.stdout_only(format!("{correct}\n"));
|
||||
}
|
||||
|
||||
for (arg, correct) in [
|
||||
|
@ -2427,7 +2423,7 @@ fn test_ls_quoting_style() {
|
|||
.arg(arg)
|
||||
.arg("one\\two")
|
||||
.succeeds()
|
||||
.stdout_only(format!("{}\n", correct));
|
||||
.stdout_only(format!("{correct}\n"));
|
||||
}
|
||||
|
||||
// Tests for a character that forces quotation in shell-style escaping
|
||||
|
@ -2443,7 +2439,7 @@ fn test_ls_quoting_style() {
|
|||
.arg(arg)
|
||||
.arg("one\n&two")
|
||||
.succeeds()
|
||||
.stdout_only(format!("{}\n", correct));
|
||||
.stdout_only(format!("{correct}\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2474,7 +2470,7 @@ fn test_ls_quoting_style() {
|
|||
.arg(arg)
|
||||
.arg("one two")
|
||||
.succeeds()
|
||||
.stdout_only(format!("{}\n", correct));
|
||||
.stdout_only(format!("{correct}\n"));
|
||||
}
|
||||
|
||||
scene.ucmd().arg("one").succeeds().stdout_only("one\n");
|
||||
|
@ -2498,7 +2494,7 @@ fn test_ls_quoting_style() {
|
|||
.arg(arg)
|
||||
.arg("one")
|
||||
.succeeds()
|
||||
.stdout_only(format!("{}\n", correct));
|
||||
.stdout_only(format!("{correct}\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3028,31 +3024,31 @@ fn test_ls_path() {
|
|||
let file1 = "file1";
|
||||
let file2 = "file2";
|
||||
let dir = "dir";
|
||||
let path = &format!("{}/{}", dir, file2);
|
||||
let path = &format!("{dir}/{file2}");
|
||||
|
||||
at.mkdir(dir);
|
||||
at.touch(file1);
|
||||
at.touch(path);
|
||||
|
||||
let expected_stdout = &format!("{}\n", path);
|
||||
let expected_stdout = &format!("{path}\n");
|
||||
scene.ucmd().arg(path).run().stdout_is(expected_stdout);
|
||||
|
||||
let expected_stdout = &format!("./{}\n", path);
|
||||
let expected_stdout = &format!("./{path}\n");
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(format!("./{}", path))
|
||||
.arg(format!("./{path}"))
|
||||
.run()
|
||||
.stdout_is(expected_stdout);
|
||||
|
||||
let abs_path = format!("{}/{}", at.as_string(), path);
|
||||
let expected_stdout = if cfg!(windows) {
|
||||
format!("\'{}\'\n", abs_path)
|
||||
format!("\'{abs_path}\'\n")
|
||||
} else {
|
||||
format!("{}\n", abs_path)
|
||||
format!("{abs_path}\n")
|
||||
};
|
||||
scene.ucmd().arg(&abs_path).run().stdout_is(expected_stdout);
|
||||
|
||||
let expected_stdout = format!("{}\n{}\n", path, file1);
|
||||
let expected_stdout = format!("{path}\n{file1}\n");
|
||||
scene
|
||||
.ucmd()
|
||||
.arg(file1)
|
||||
|
|
|
@ -473,8 +473,7 @@ fn test_tmpdir_absolute_path() {
|
|||
.args(&["--tmpdir=a", path])
|
||||
.fails()
|
||||
.stderr_only(format!(
|
||||
"mktemp: invalid template, '{}'; with --tmpdir, it may not be absolute\n",
|
||||
path
|
||||
"mktemp: invalid template, '{path}'; with --tmpdir, it may not be absolute\n"
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -691,7 +690,7 @@ fn test_tmpdir_env_var() {
|
|||
let filename = result.no_stderr().stdout_str().trim_end();
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
let template = format!(".{}tmp.XXXXXXXXXX", MAIN_SEPARATOR);
|
||||
let template = format!(".{MAIN_SEPARATOR}tmp.XXXXXXXXXX");
|
||||
assert_matches_template!(&template, filename);
|
||||
}
|
||||
// On Windows, `env::temp_dir()` seems to give an absolute path
|
||||
|
@ -720,7 +719,7 @@ fn test_tmpdir_env_var() {
|
|||
let filename = result.no_stderr().stdout_str().trim_end();
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
let template = format!(".{}XXX", MAIN_SEPARATOR);
|
||||
let template = format!(".{MAIN_SEPARATOR}XXX");
|
||||
assert_matches_template!(&template, filename);
|
||||
}
|
||||
#[cfg(windows)]
|
||||
|
|
|
@ -55,7 +55,7 @@ fn test_mv_move_file_into_dir() {
|
|||
|
||||
ucmd.arg(file).arg(dir).succeeds().no_stderr();
|
||||
|
||||
assert!(at.file_exists(&format!("{}/{}", dir, file)));
|
||||
assert!(at.file_exists(&format!("{dir}/{file}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -67,17 +67,17 @@ fn test_mv_move_file_between_dirs() {
|
|||
|
||||
at.mkdir(dir1);
|
||||
at.mkdir(dir2);
|
||||
at.touch(&format!("{}/{}", dir1, file));
|
||||
at.touch(&format!("{dir1}/{file}"));
|
||||
|
||||
assert!(at.file_exists(&format!("{}/{}", dir1, file)));
|
||||
assert!(at.file_exists(&format!("{dir1}/{file}")));
|
||||
|
||||
ucmd.arg(&format!("{}/{}", dir1, file))
|
||||
ucmd.arg(&format!("{dir1}/{file}"))
|
||||
.arg(dir2)
|
||||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
assert!(!at.file_exists(&format!("{}/{}", dir1, file)));
|
||||
assert!(at.file_exists(&format!("{}/{}", dir2, file)));
|
||||
assert!(!at.file_exists(&format!("{dir1}/{file}")));
|
||||
assert!(at.file_exists(&format!("{dir2}/{file}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -94,7 +94,7 @@ fn test_mv_strip_slashes() {
|
|||
|
||||
scene.ucmd().arg(&source).arg(dir).fails();
|
||||
|
||||
assert!(!at.file_exists(&format!("{}/{}", dir, file)));
|
||||
assert!(!at.file_exists(&format!("{dir}/{file}")));
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -104,7 +104,7 @@ fn test_mv_strip_slashes() {
|
|||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
assert!(at.file_exists(&format!("{}/{}", dir, file)));
|
||||
assert!(at.file_exists(&format!("{dir}/{file}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -124,8 +124,8 @@ fn test_mv_multiple_files() {
|
|||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
assert!(at.file_exists(&format!("{}/{}", target_dir, file_a)));
|
||||
assert!(at.file_exists(&format!("{}/{}", target_dir, file_b)));
|
||||
assert!(at.file_exists(&format!("{target_dir}/{file_a}")));
|
||||
assert!(at.file_exists(&format!("{target_dir}/{file_b}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -145,8 +145,8 @@ fn test_mv_multiple_folders() {
|
|||
.succeeds()
|
||||
.no_stderr();
|
||||
|
||||
assert!(at.dir_exists(&format!("{}/{}", target_dir, dir_a)));
|
||||
assert!(at.dir_exists(&format!("{}/{}", target_dir, dir_b)));
|
||||
assert!(at.dir_exists(&format!("{target_dir}/{dir_a}")));
|
||||
assert!(at.dir_exists(&format!("{target_dir}/{dir_b}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -262,10 +262,10 @@ fn test_mv_same_file() {
|
|||
let file_a = "test_mv_same_file_a";
|
||||
|
||||
at.touch(file_a);
|
||||
ucmd.arg(file_a).arg(file_a).fails().stderr_is(format!(
|
||||
"mv: '{f}' and '{f}' are the same file\n",
|
||||
f = file_a,
|
||||
));
|
||||
ucmd.arg(file_a)
|
||||
.arg(file_a)
|
||||
.fails()
|
||||
.stderr_is(format!("mv: '{file_a}' and '{file_a}' are the same file\n",));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -275,8 +275,7 @@ fn test_mv_same_file_not_dot_dir() {
|
|||
|
||||
at.mkdir(dir);
|
||||
ucmd.arg(dir).arg(dir).fails().stderr_is(format!(
|
||||
"mv: cannot move '{d}' to a subdirectory of itself, '{d}/{d}'\n",
|
||||
d = dir,
|
||||
"mv: cannot move '{dir}' to a subdirectory of itself, '{dir}/{dir}'\n",
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -306,7 +305,7 @@ fn test_mv_simple_backup() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -325,7 +324,7 @@ fn test_mv_simple_backup_with_file_extension() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -340,7 +339,7 @@ fn test_mv_arg_backup_arg_first() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -353,7 +352,7 @@ fn test_mv_custom_backup_suffix() {
|
|||
at.touch(file_a);
|
||||
at.touch(file_b);
|
||||
ucmd.arg("-b")
|
||||
.arg(format!("--suffix={}", suffix))
|
||||
.arg(format!("--suffix={suffix}"))
|
||||
.arg(file_a)
|
||||
.arg(file_b)
|
||||
.succeeds()
|
||||
|
@ -361,7 +360,7 @@ fn test_mv_custom_backup_suffix() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}{}", file_b, suffix)));
|
||||
assert!(at.file_exists(&format!("{file_b}{suffix}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -374,7 +373,7 @@ fn test_mv_custom_backup_suffix_hyphen_value() {
|
|||
at.touch(file_a);
|
||||
at.touch(file_b);
|
||||
ucmd.arg("-b")
|
||||
.arg(format!("--suffix={}", suffix))
|
||||
.arg(format!("--suffix={suffix}"))
|
||||
.arg(file_a)
|
||||
.arg(file_b)
|
||||
.succeeds()
|
||||
|
@ -382,7 +381,7 @@ fn test_mv_custom_backup_suffix_hyphen_value() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}{}", file_b, suffix)));
|
||||
assert!(at.file_exists(&format!("{file_b}{suffix}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -402,7 +401,7 @@ fn test_mv_custom_backup_suffix_via_env() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}{}", file_b, suffix)));
|
||||
assert!(at.file_exists(&format!("{file_b}{suffix}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -421,7 +420,7 @@ fn test_mv_backup_numbered_with_t() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}.~1~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}.~1~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -440,7 +439,7 @@ fn test_mv_backup_numbered() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}.~1~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}.~1~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -459,7 +458,7 @@ fn test_mv_backup_existing() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -478,7 +477,7 @@ fn test_mv_backup_nil() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -499,7 +498,7 @@ fn test_mv_numbered_if_existing_backup_existing() {
|
|||
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(file_b_backup));
|
||||
assert!(at.file_exists(&format!("{}.~2~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}.~2~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -520,7 +519,7 @@ fn test_mv_numbered_if_existing_backup_nil() {
|
|||
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(file_b_backup));
|
||||
assert!(at.file_exists(&format!("{}.~2~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}.~2~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -539,7 +538,7 @@ fn test_mv_backup_simple() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -558,7 +557,7 @@ fn test_mv_backup_never() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -577,7 +576,7 @@ fn test_mv_backup_none() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(!at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(!at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -596,7 +595,7 @@ fn test_mv_backup_off() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(at.file_exists(file_b));
|
||||
assert!(!at.file_exists(&format!("{}~", file_b)));
|
||||
assert!(!at.file_exists(&format!("{file_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -661,8 +660,8 @@ fn test_mv_target_dir() {
|
|||
|
||||
assert!(!at.file_exists(file_a));
|
||||
assert!(!at.file_exists(file_b));
|
||||
assert!(at.file_exists(&format!("{}/{}", dir, file_a)));
|
||||
assert!(at.file_exists(&format!("{}/{}", dir, file_b)));
|
||||
assert!(at.file_exists(&format!("{dir}/{file_a}")));
|
||||
assert!(at.file_exists(&format!("{dir}/{file_b}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -676,7 +675,7 @@ fn test_mv_target_dir_single_source() {
|
|||
ucmd.arg("-t").arg(dir).arg(file).succeeds().no_stderr();
|
||||
|
||||
assert!(!at.file_exists(file));
|
||||
assert!(at.file_exists(&format!("{}/{}", dir, file)));
|
||||
assert!(at.file_exists(&format!("{dir}/{file}")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -729,14 +728,11 @@ fn test_mv_backup_dir() {
|
|||
.arg(dir_a)
|
||||
.arg(dir_b)
|
||||
.succeeds()
|
||||
.stdout_only(format!(
|
||||
"'{}' -> '{}' (backup: '{}~')\n",
|
||||
dir_a, dir_b, dir_b
|
||||
));
|
||||
.stdout_only(format!("'{dir_a}' -> '{dir_b}' (backup: '{dir_b}~')\n"));
|
||||
|
||||
assert!(!at.dir_exists(dir_a));
|
||||
assert!(at.dir_exists(dir_b));
|
||||
assert!(at.dir_exists(&format!("{}~", dir_b)));
|
||||
assert!(at.dir_exists(&format!("{dir_b}~")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -772,8 +768,7 @@ fn test_mv_errors() {
|
|||
.arg(dir)
|
||||
.fails()
|
||||
.stderr_is(format!(
|
||||
"mv: cannot overwrite directory '{}' with non-directory\n",
|
||||
dir
|
||||
"mv: cannot overwrite directory '{dir}' with non-directory\n"
|
||||
));
|
||||
|
||||
// $ at.mkdir dir && at.touch file
|
||||
|
@ -805,7 +800,7 @@ fn test_mv_verbose() {
|
|||
.arg(file_a)
|
||||
.arg(file_b)
|
||||
.succeeds()
|
||||
.stdout_only(format!("'{}' -> '{}'\n", file_a, file_b));
|
||||
.stdout_only(format!("'{file_a}' -> '{file_b}'\n"));
|
||||
|
||||
at.touch(file_a);
|
||||
scene
|
||||
|
@ -814,10 +809,7 @@ fn test_mv_verbose() {
|
|||
.arg(file_a)
|
||||
.arg(file_b)
|
||||
.succeeds()
|
||||
.stdout_only(format!(
|
||||
"'{}' -> '{}' (backup: '{}~')\n",
|
||||
file_a, file_b, file_b
|
||||
));
|
||||
.stdout_only(format!("'{file_a}' -> '{file_b}' (backup: '{file_b}~')\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -60,8 +60,7 @@ fn test_from_iec_i_requires_suffix() {
|
|||
.fails()
|
||||
.code_is(2)
|
||||
.stderr_is(format!(
|
||||
"numfmt: missing 'i' suffix in input: '{}' (e.g Ki/Mi/Gi)\n",
|
||||
number
|
||||
"numfmt: missing 'i' suffix in input: '{number}' (e.g Ki/Mi/Gi)\n"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -687,11 +686,11 @@ fn test_invalid_padding_value() {
|
|||
|
||||
for padding_value in padding_values {
|
||||
new_ucmd!()
|
||||
.arg(format!("--padding={}", padding_value))
|
||||
.arg(format!("--padding={padding_value}"))
|
||||
.arg("5")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains(format!("invalid padding value '{}'", padding_value));
|
||||
.stderr_contains(format!("invalid padding value '{padding_value}'"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -719,10 +718,10 @@ fn test_invalid_unit_size() {
|
|||
for command in commands {
|
||||
for invalid_size in &invalid_sizes {
|
||||
new_ucmd!()
|
||||
.arg(format!("--{}-unit={}", command, invalid_size))
|
||||
.arg(format!("--{command}-unit={invalid_size}"))
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains(format!("invalid unit size: '{}'", invalid_size));
|
||||
.stderr_contains(format!("invalid unit size: '{invalid_size}'"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -737,8 +736,7 @@ fn test_valid_but_forbidden_suffix() {
|
|||
.fails()
|
||||
.code_is(2)
|
||||
.stderr_contains(format!(
|
||||
"rejecting suffix in input: '{}' (consider using --from)",
|
||||
number
|
||||
"rejecting suffix in input: '{number}' (consider using --from)"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -805,7 +803,7 @@ fn test_format_with_zero_padding() {
|
|||
|
||||
for format in formats {
|
||||
new_ucmd!()
|
||||
.args(&[format!("--format={}", format), String::from("1234")])
|
||||
.args(&[format!("--format={format}"), String::from("1234")])
|
||||
.succeeds()
|
||||
.stdout_is("001234\n");
|
||||
}
|
||||
|
@ -851,7 +849,7 @@ fn test_format_with_precision() {
|
|||
new_ucmd!()
|
||||
.args(&["--format=%.1f", input])
|
||||
.succeeds()
|
||||
.stdout_is(format!("{}\n", expected));
|
||||
.stdout_is(format!("{expected}\n"));
|
||||
}
|
||||
|
||||
let values = vec![("0.99", "0.99"), ("1", "1.00"), ("1.01", "1.01")];
|
||||
|
@ -860,7 +858,7 @@ fn test_format_with_precision() {
|
|||
new_ucmd!()
|
||||
.args(&["--format=%.2f", input])
|
||||
.succeeds()
|
||||
.stdout_is(format!("{}\n", expected));
|
||||
.stdout_is(format!("{expected}\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -872,7 +870,7 @@ fn test_format_with_precision_and_down_rounding() {
|
|||
new_ucmd!()
|
||||
.args(&["--format=%.1f", input, "--round=down"])
|
||||
.succeeds()
|
||||
.stdout_is(format!("{}\n", expected));
|
||||
.stdout_is(format!("{expected}\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -883,12 +881,12 @@ fn test_format_with_precision_and_to_arg() {
|
|||
for (format, expected) in values {
|
||||
new_ucmd!()
|
||||
.args(&[
|
||||
format!("--format={}", format),
|
||||
format!("--format={format}"),
|
||||
"9991239123".to_string(),
|
||||
"--to=si".to_string(),
|
||||
])
|
||||
.succeeds()
|
||||
.stdout_is(format!("{}\n", expected));
|
||||
.stdout_is(format!("{expected}\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -900,7 +898,7 @@ fn test_format_preserve_trailing_zeros_if_no_precision_is_specified() {
|
|||
new_ucmd!()
|
||||
.args(&["--format=%f", value])
|
||||
.succeeds()
|
||||
.stdout_is(format!("{}\n", value));
|
||||
.stdout_is(format!("{value}\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -910,10 +908,10 @@ fn test_format_without_percentage_directive() {
|
|||
|
||||
for invalid_format in invalid_formats {
|
||||
new_ucmd!()
|
||||
.arg(format!("--format={}", invalid_format))
|
||||
.arg(format!("--format={invalid_format}"))
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains(format!("format '{}' has no % directive", invalid_format));
|
||||
.stderr_contains(format!("format '{invalid_format}' has no % directive"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -922,10 +920,10 @@ fn test_format_with_percentage_directive_at_end() {
|
|||
let invalid_format = "hello%";
|
||||
|
||||
new_ucmd!()
|
||||
.arg(format!("--format={}", invalid_format))
|
||||
.arg(format!("--format={invalid_format}"))
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains(format!("format '{}' ends in %", invalid_format));
|
||||
.stderr_contains(format!("format '{invalid_format}' ends in %"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -933,12 +931,11 @@ fn test_format_with_too_many_percentage_directives() {
|
|||
let invalid_format = "%f %f";
|
||||
|
||||
new_ucmd!()
|
||||
.arg(format!("--format={}", invalid_format))
|
||||
.arg(format!("--format={invalid_format}"))
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains(format!(
|
||||
"format '{}' has too many % directives",
|
||||
invalid_format
|
||||
"format '{invalid_format}' has too many % directives"
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -948,12 +945,11 @@ fn test_format_with_invalid_format() {
|
|||
|
||||
for invalid_format in invalid_formats {
|
||||
new_ucmd!()
|
||||
.arg(format!("--format={}", invalid_format))
|
||||
.arg(format!("--format={invalid_format}"))
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains(format!(
|
||||
"invalid format '{}', directive must be %[0]['][-][N][.][N]f",
|
||||
invalid_format
|
||||
"invalid format '{invalid_format}', directive must be %[0]['][-][N][.][N]f"
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -962,12 +958,11 @@ fn test_format_with_invalid_format() {
|
|||
fn test_format_with_width_overflow() {
|
||||
let invalid_format = "%18446744073709551616f";
|
||||
new_ucmd!()
|
||||
.arg(format!("--format={}", invalid_format))
|
||||
.arg(format!("--format={invalid_format}"))
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains(format!(
|
||||
"invalid format '{}' (width overflow)",
|
||||
invalid_format
|
||||
"invalid format '{invalid_format}' (width overflow)"
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -977,10 +972,10 @@ fn test_format_with_invalid_precision() {
|
|||
|
||||
for invalid_format in invalid_formats {
|
||||
new_ucmd!()
|
||||
.arg(format!("--format={}", invalid_format))
|
||||
.arg(format!("--format={invalid_format}"))
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains(format!("invalid precision in format '{}'", invalid_format));
|
||||
.stderr_contains(format!("invalid precision in format '{invalid_format}'"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ fn test_2files() {
|
|||
let file2 = tmpdir.join("test2");
|
||||
|
||||
for (n, a) in [(1, "a"), (2, "b")] {
|
||||
println!("number: {} letter:{}", n, a);
|
||||
println!("number: {n} letter:{a}");
|
||||
}
|
||||
|
||||
// spell-checker:disable-next-line
|
||||
|
@ -849,34 +849,27 @@ fn test_od_invalid_bytes() {
|
|||
];
|
||||
for option in &options {
|
||||
new_ucmd!()
|
||||
.arg(format!("{}={}", option, INVALID_SIZE))
|
||||
.arg(format!("{option}={INVALID_SIZE}"))
|
||||
.arg("file")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_only(format!(
|
||||
"od: invalid {} argument '{}'\n",
|
||||
option, INVALID_SIZE
|
||||
));
|
||||
.stderr_only(format!("od: invalid {option} argument '{INVALID_SIZE}'\n"));
|
||||
|
||||
new_ucmd!()
|
||||
.arg(format!("{}={}", option, INVALID_SUFFIX))
|
||||
.arg(format!("{option}={INVALID_SUFFIX}"))
|
||||
.arg("file")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_only(format!(
|
||||
"od: invalid suffix in {} argument '{}'\n",
|
||||
option, INVALID_SUFFIX
|
||||
"od: invalid suffix in {option} argument '{INVALID_SUFFIX}'\n"
|
||||
));
|
||||
|
||||
#[cfg(not(target_pointer_width = "128"))]
|
||||
new_ucmd!()
|
||||
.arg(format!("{}={}", option, BIG_SIZE))
|
||||
.arg(format!("{option}={BIG_SIZE}"))
|
||||
.arg("file")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_only(format!(
|
||||
"od: {} argument '{}' too large\n",
|
||||
option, BIG_SIZE
|
||||
));
|
||||
.stderr_only(format!("od: {option} argument '{BIG_SIZE}' too large\n"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -162,7 +162,7 @@ fn test_data() {
|
|||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let mut ins = vec![];
|
||||
for (i, _in) in example.ins.iter().enumerate() {
|
||||
let file = format!("in{}", i);
|
||||
let file = format!("in{i}");
|
||||
at.write(&file, _in);
|
||||
ins.push(file);
|
||||
}
|
||||
|
|
|
@ -35,8 +35,7 @@ fn test_long_format() {
|
|||
let real_name = user_info.replace('&', &pw.name.capitalize());
|
||||
let ts = TestScenario::new(util_name!());
|
||||
ts.ucmd().arg("-l").arg(login).succeeds().stdout_is(format!(
|
||||
"Login name: {:<28}In real life: {}\nDirectory: {:<29}Shell: {}\n\n",
|
||||
login, real_name, user_dir, user_shell
|
||||
"Login name: {login:<28}In real life: {real_name}\nDirectory: {user_dir:<29}Shell: {user_shell}\n\n"
|
||||
));
|
||||
|
||||
ts.ucmd()
|
||||
|
@ -44,8 +43,7 @@ fn test_long_format() {
|
|||
.arg(login)
|
||||
.succeeds()
|
||||
.stdout_is(format!(
|
||||
"Login name: {:<28}In real life: {1}\n\n",
|
||||
login, real_name
|
||||
"Login name: {login:<28}In real life: {real_name}\n\n"
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ fn test_canonicalize() {
|
|||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let actual = ucmd.arg("-f").arg(".").run().stdout_move_str();
|
||||
let expect = at.root_dir_resolved() + "\n";
|
||||
println!("actual: {:?}", actual);
|
||||
println!("expect: {:?}", expect);
|
||||
println!("actual: {actual:?}");
|
||||
println!("expect: {expect:?}");
|
||||
assert_eq!(actual, expect);
|
||||
}
|
||||
|
||||
|
@ -39,8 +39,8 @@ fn test_canonicalize_existing() {
|
|||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let actual = ucmd.arg("-e").arg(".").run().stdout_move_str();
|
||||
let expect = at.root_dir_resolved() + "\n";
|
||||
println!("actual: {:?}", actual);
|
||||
println!("expect: {:?}", expect);
|
||||
println!("actual: {actual:?}");
|
||||
println!("expect: {expect:?}");
|
||||
assert_eq!(actual, expect);
|
||||
}
|
||||
|
||||
|
@ -49,8 +49,8 @@ fn test_canonicalize_missing() {
|
|||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let actual = ucmd.arg("-m").arg(GIBBERISH).run().stdout_move_str();
|
||||
let expect = path_concat!(at.root_dir_resolved(), GIBBERISH) + "\n";
|
||||
println!("actual: {:?}", actual);
|
||||
println!("expect: {:?}", expect);
|
||||
println!("actual: {actual:?}");
|
||||
println!("expect: {expect:?}");
|
||||
assert_eq!(actual, expect);
|
||||
}
|
||||
|
||||
|
@ -61,8 +61,8 @@ fn test_long_redirection_to_current_dir() {
|
|||
let dir = path_concat!(".", ..128);
|
||||
let actual = ucmd.arg("-n").arg("-m").arg(dir).run().stdout_move_str();
|
||||
let expect = at.root_dir_resolved();
|
||||
println!("actual: {:?}", actual);
|
||||
println!("expect: {:?}", expect);
|
||||
println!("actual: {actual:?}");
|
||||
println!("expect: {expect:?}");
|
||||
assert_eq!(actual, expect);
|
||||
}
|
||||
|
||||
|
@ -77,8 +77,8 @@ fn test_long_redirection_to_root() {
|
|||
.run()
|
||||
.stdout_move_str();
|
||||
let expect = get_root_path();
|
||||
println!("actual: {:?}", actual);
|
||||
println!("expect: {:?}", expect);
|
||||
println!("actual: {actual:?}");
|
||||
println!("expect: {expect:?}");
|
||||
assert_eq!(actual, expect);
|
||||
}
|
||||
|
||||
|
@ -214,21 +214,21 @@ fn test_canonicalize_trailing_slash_regfile() {
|
|||
.stdout_contains("regfile");
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-fv", &format!("./{}/", name)])
|
||||
.args(&["-fv", &format!("./{name}/")])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains(NOT_A_DIRECTORY)
|
||||
.no_stdout();
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-fv", &format!("{}/more", name)])
|
||||
.args(&["-fv", &format!("{name}/more")])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains(NOT_A_DIRECTORY)
|
||||
.no_stdout();
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-fv", &format!("./{}/more/", name)])
|
||||
.args(&["-fv", &format!("./{name}/more/")])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.stderr_contains(NOT_A_DIRECTORY)
|
||||
|
@ -250,28 +250,28 @@ fn test_canonicalize_trailing_slash_subdir() {
|
|||
.stdout_contains("subdir");
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-f", &format!("./{}/", name)])
|
||||
.args(&["-f", &format!("./{name}/")])
|
||||
.succeeds()
|
||||
.stdout_contains("subdir");
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-f", &format!("{}/more", name)])
|
||||
.args(&["-f", &format!("{name}/more")])
|
||||
.succeeds()
|
||||
.stdout_contains(path_concat!("subdir", "more"));
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-f", &format!("./{}/more/", name)])
|
||||
.args(&["-f", &format!("./{name}/more/")])
|
||||
.succeeds()
|
||||
.stdout_contains(path_concat!("subdir", "more"));
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-f", &format!("{}/more/more2", name)])
|
||||
.args(&["-f", &format!("{name}/more/more2")])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.no_stdout();
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-f", &format!("./{}/more/more2/", name)])
|
||||
.args(&["-f", &format!("./{name}/more/more2/")])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.no_stdout();
|
||||
|
@ -291,18 +291,18 @@ fn test_canonicalize_trailing_slash_missing() {
|
|||
.stdout_contains("missing");
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-f", &format!("./{}/", name)])
|
||||
.args(&["-f", &format!("./{name}/")])
|
||||
.succeeds()
|
||||
.stdout_contains("missing");
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-f", &format!("{}/more", name)])
|
||||
.args(&["-f", &format!("{name}/more")])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.no_stdout();
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["-f", &format!("./{}/more/", name)])
|
||||
.args(&["-f", &format!("./{name}/more/")])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.no_stdout();
|
||||
|
|
|
@ -255,8 +255,8 @@ fn test_realpath_when_symlink_part_is_missing() {
|
|||
at.relative_symlink_file("../dir2/baz", "dir1/foo3");
|
||||
at.symlink_file("dir3/bar", "dir1/foo4");
|
||||
|
||||
let expect1 = format!("dir2{}bar", MAIN_SEPARATOR);
|
||||
let expect2 = format!("dir2{}baz", MAIN_SEPARATOR);
|
||||
let expect1 = format!("dir2{MAIN_SEPARATOR}bar");
|
||||
let expect2 = format!("dir2{MAIN_SEPARATOR}baz");
|
||||
|
||||
ucmd.args(&["dir1/foo1", "dir1/foo2", "dir1/foo3", "dir1/foo4"])
|
||||
.run()
|
||||
|
|
|
@ -87,7 +87,7 @@ fn test_relpath_with_from_no_d() {
|
|||
.arg(to)
|
||||
.arg(from)
|
||||
.succeeds()
|
||||
.stdout_only(&format!("{}\n", expected));
|
||||
.stdout_only(&format!("{expected}\n"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ fn test_relpath_with_from_with_d() {
|
|||
.ucmd()
|
||||
.arg(to)
|
||||
.arg(from)
|
||||
.arg(&format!("-d{}", pwd))
|
||||
.arg(&format!("-d{pwd}"))
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
// relax rules for windows test environment
|
||||
|
@ -138,10 +138,10 @@ fn test_relpath_no_from_no_d() {
|
|||
|
||||
let _result_stdout = scene.ucmd().arg(to).succeeds().stdout_move_str();
|
||||
#[cfg(not(windows))]
|
||||
assert_eq!(_result_stdout, format!("{}\n", to));
|
||||
assert_eq!(_result_stdout, format!("{to}\n"));
|
||||
// relax rules for windows test environment
|
||||
#[cfg(windows)]
|
||||
assert!(_result_stdout.ends_with(&format!("{}\n", to)));
|
||||
assert!(_result_stdout.ends_with(&format!("{to}\n")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -159,7 +159,7 @@ fn test_relpath_no_from_with_d() {
|
|||
let _result_stdout = scene
|
||||
.ucmd()
|
||||
.arg(to)
|
||||
.arg(&format!("-d{}", pwd))
|
||||
.arg(&format!("-d{pwd}"))
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
// relax rules for windows test environment
|
||||
|
|
|
@ -25,8 +25,7 @@ fn test_rm_failed() {
|
|||
let file = "test_rm_one_file"; // Doesn't exist
|
||||
|
||||
ucmd.arg(file).fails().stderr_contains(&format!(
|
||||
"cannot remove '{}': No such file or directory",
|
||||
file
|
||||
"cannot remove '{file}': No such file or directory"
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -136,7 +135,7 @@ fn test_rm_empty_directory_verbose() {
|
|||
.arg("-v")
|
||||
.arg(dir)
|
||||
.succeeds()
|
||||
.stdout_only(format!("removed directory '{}'\n", dir));
|
||||
.stdout_only(format!("removed directory '{dir}'\n"));
|
||||
|
||||
assert!(!at.dir_exists(dir));
|
||||
}
|
||||
|
@ -145,7 +144,7 @@ fn test_rm_empty_directory_verbose() {
|
|||
fn test_rm_non_empty_directory() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let dir = "test_rm_non_empty_dir";
|
||||
let file_a = &format!("{}/test_rm_non_empty_file_a", dir);
|
||||
let file_a = &format!("{dir}/test_rm_non_empty_file_a");
|
||||
|
||||
at.mkdir(dir);
|
||||
at.touch(file_a);
|
||||
|
@ -153,7 +152,7 @@ fn test_rm_non_empty_directory() {
|
|||
ucmd.arg("-d")
|
||||
.arg(dir)
|
||||
.fails()
|
||||
.stderr_contains(&format!("cannot remove '{}': Directory not empty", dir));
|
||||
.stderr_contains(&format!("cannot remove '{dir}': Directory not empty"));
|
||||
assert!(at.file_exists(file_a));
|
||||
assert!(at.dir_exists(dir));
|
||||
}
|
||||
|
@ -208,7 +207,7 @@ fn test_rm_directory_without_flag() {
|
|||
|
||||
ucmd.arg(dir)
|
||||
.fails()
|
||||
.stderr_contains(&format!("cannot remove '{}': Is a directory", dir));
|
||||
.stderr_contains(&format!("cannot remove '{dir}': Is a directory"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -224,7 +223,7 @@ fn test_rm_verbose() {
|
|||
.arg(file_a)
|
||||
.arg(file_b)
|
||||
.succeeds()
|
||||
.stdout_only(format!("removed '{}'\nremoved '{}'\n", file_a, file_b));
|
||||
.stdout_only(format!("removed '{file_a}'\nremoved '{file_b}'\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -259,7 +258,7 @@ fn test_rm_symlink_dir() {
|
|||
.ucmd()
|
||||
.arg(link)
|
||||
.fails()
|
||||
.stderr_contains(&format!("cannot remove '{}': Is a directory", link));
|
||||
.stderr_contains(&format!("cannot remove '{link}': Is a directory"));
|
||||
|
||||
assert!(at.dir_exists(link));
|
||||
|
||||
|
@ -293,7 +292,7 @@ fn test_rm_no_operand() {
|
|||
fn test_rm_verbose_slash() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let dir = "test_rm_verbose_slash_directory";
|
||||
let file_a = &format!("{}/test_rm_verbose_slash_file_a", dir);
|
||||
let file_a = &format!("{dir}/test_rm_verbose_slash_file_a");
|
||||
|
||||
at.mkdir(dir);
|
||||
at.touch(file_a);
|
||||
|
@ -307,11 +306,10 @@ fn test_rm_verbose_slash() {
|
|||
ucmd.arg("-r")
|
||||
.arg("-f")
|
||||
.arg("-v")
|
||||
.arg(&format!("{}///", dir))
|
||||
.arg(&format!("{dir}///"))
|
||||
.succeeds()
|
||||
.stdout_only(format!(
|
||||
"removed '{}'\nremoved directory '{}'\n",
|
||||
file_a_normalized, dir
|
||||
"removed '{file_a_normalized}'\nremoved directory '{dir}'\n"
|
||||
));
|
||||
|
||||
assert!(!at.dir_exists(dir));
|
||||
|
@ -359,7 +357,7 @@ fn test_rm_descend_directory() {
|
|||
// Needed for talking with stdin on platforms where CRLF or LF matters
|
||||
const END_OF_LINE: &str = if cfg!(windows) { "\r\n" } else { "\n" };
|
||||
|
||||
let yes = format!("y{}", END_OF_LINE);
|
||||
let yes = format!("y{END_OF_LINE}");
|
||||
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
@ -414,7 +412,7 @@ fn test_rm_prompts() {
|
|||
|
||||
answers.sort();
|
||||
|
||||
let yes = format!("y{}", END_OF_LINE);
|
||||
let yes = format!("y{END_OF_LINE}");
|
||||
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
@ -463,7 +461,7 @@ fn test_rm_prompts() {
|
|||
let mut trimmed_output = Vec::new();
|
||||
for string in result.stderr_str().split("rm: ") {
|
||||
if !string.is_empty() {
|
||||
let trimmed_string = format!("rm: {}", string).trim().to_string();
|
||||
let trimmed_string = format!("rm: {string}").trim().to_string();
|
||||
trimmed_output.push(trimmed_string);
|
||||
}
|
||||
}
|
||||
|
@ -484,7 +482,7 @@ fn test_rm_force_prompts_order() {
|
|||
// Needed for talking with stdin on platforms where CRLF or LF matters
|
||||
const END_OF_LINE: &str = if cfg!(windows) { "\r\n" } else { "\n" };
|
||||
|
||||
let yes = format!("y{}", END_OF_LINE);
|
||||
let yes = format!("y{END_OF_LINE}");
|
||||
|
||||
let scene = TestScenario::new(util_name!());
|
||||
let at = &scene.fixtures;
|
||||
|
|
|
@ -57,7 +57,7 @@ fn test_rmdir_nonempty_directory_no_parents() {
|
|||
|
||||
ucmd.arg(DIR)
|
||||
.fails()
|
||||
.stderr_is(format!("rmdir: failed to remove 'dir': {}\n", NOT_EMPTY));
|
||||
.stderr_is(format!("rmdir: failed to remove 'dir': {NOT_EMPTY}\n"));
|
||||
|
||||
assert!(at.dir_exists(DIR));
|
||||
}
|
||||
|
@ -70,8 +70,7 @@ fn test_rmdir_nonempty_directory_with_parents() {
|
|||
at.touch(NESTED_DIR_FILE);
|
||||
|
||||
ucmd.arg("-p").arg(NESTED_DIR).fails().stderr_is(format!(
|
||||
"rmdir: failed to remove 'dir/ect/ory': {}\n",
|
||||
NOT_EMPTY
|
||||
"rmdir: failed to remove 'dir/ect/ory': {NOT_EMPTY}\n"
|
||||
));
|
||||
|
||||
assert!(at.dir_exists(NESTED_DIR));
|
||||
|
@ -119,8 +118,7 @@ fn test_rmdir_not_a_directory() {
|
|||
.fails()
|
||||
.no_stdout()
|
||||
.stderr_is(format!(
|
||||
"rmdir: failed to remove 'file': {}\n",
|
||||
NOT_A_DIRECTORY
|
||||
"rmdir: failed to remove 'file': {NOT_A_DIRECTORY}\n"
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -152,8 +150,7 @@ fn test_verbose_multi() {
|
|||
rmdir: removing directory, 'dir'\n",
|
||||
)
|
||||
.stderr_is(format!(
|
||||
"rmdir: failed to remove 'does_not_exist': {}\n",
|
||||
NOT_FOUND
|
||||
"rmdir: failed to remove 'does_not_exist': {NOT_FOUND}\n"
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -171,10 +168,7 @@ fn test_verbose_nested_failure() {
|
|||
"rmdir: removing directory, 'dir/ect/ory'\n\
|
||||
rmdir: removing directory, 'dir/ect'\n",
|
||||
)
|
||||
.stderr_is(format!(
|
||||
"rmdir: failed to remove 'dir/ect': {}\n",
|
||||
NOT_EMPTY
|
||||
));
|
||||
.stderr_is(format!("rmdir: failed to remove 'dir/ect': {NOT_EMPTY}\n"));
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
|
@ -214,8 +208,7 @@ fn test_rmdir_remove_symlink_file() {
|
|||
at.symlink_file("file", "fl");
|
||||
|
||||
ucmd.arg("fl/").fails().stderr_is(format!(
|
||||
"rmdir: failed to remove 'fl/': {}\n",
|
||||
NOT_A_DIRECTORY
|
||||
"rmdir: failed to remove 'fl/': {NOT_A_DIRECTORY}\n"
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -12,17 +12,17 @@ use crate::common::util::*;
|
|||
fn test_helper(file_name: &str, possible_args: &[&str]) {
|
||||
for args in possible_args {
|
||||
new_ucmd!()
|
||||
.arg(format!("{}.txt", file_name))
|
||||
.arg(format!("{file_name}.txt"))
|
||||
.args(&args.split_whitespace().collect::<Vec<&str>>())
|
||||
.succeeds()
|
||||
.stdout_is_fixture(format!("{}.expected", file_name));
|
||||
.stdout_is_fixture(format!("{file_name}.expected"));
|
||||
|
||||
new_ucmd!()
|
||||
.arg(format!("{}.txt", file_name))
|
||||
.arg(format!("{file_name}.txt"))
|
||||
.arg("--debug")
|
||||
.args(&args.split_whitespace().collect::<Vec<&str>>())
|
||||
.succeeds()
|
||||
.stdout_is_fixture(format!("{}.expected.debug", file_name));
|
||||
.stdout_is_fixture(format!("{file_name}.expected.debug"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -810,21 +810,21 @@ fn test_dictionary_and_nonprinting_conflicts() {
|
|||
for restricted_arg in ["d", "i"] {
|
||||
for conflicting_arg in &conflicting_args {
|
||||
new_ucmd!()
|
||||
.arg(&format!("-{}{}", restricted_arg, conflicting_arg))
|
||||
.arg(&format!("-{restricted_arg}{conflicting_arg}"))
|
||||
.fails();
|
||||
}
|
||||
for conflicting_arg in &conflicting_args {
|
||||
new_ucmd!()
|
||||
.args(&[
|
||||
format!("-{}", restricted_arg).as_str(),
|
||||
format!("-{restricted_arg}").as_str(),
|
||||
"-k",
|
||||
&format!("1,1{}", conflicting_arg),
|
||||
&format!("1,1{conflicting_arg}"),
|
||||
])
|
||||
.succeeds();
|
||||
}
|
||||
for conflicting_arg in &conflicting_args {
|
||||
new_ucmd!()
|
||||
.args(&["-k", &format!("1{},1{}", restricted_arg, conflicting_arg)])
|
||||
.args(&["-k", &format!("1{restricted_arg},1{conflicting_arg}")])
|
||||
.fails();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -425,7 +425,7 @@ fn test_numeric_dynamic_suffix_length() {
|
|||
ucmd.args(&["-d", "-b", "1", "ninetyonebytes.txt"])
|
||||
.succeeds();
|
||||
for i in 0..90 {
|
||||
let filename = format!("x{:02}", i);
|
||||
let filename = format!("x{i:02}");
|
||||
let contents = file_read(&at, &filename);
|
||||
assert_eq!(contents, "a");
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ fn test_hex_dynamic_suffix_length() {
|
|||
ucmd.args(&["-x", "-b", "1", "twohundredfortyonebytes.txt"])
|
||||
.succeeds();
|
||||
for i in 0..240 {
|
||||
let filename = format!("x{:02x}", i);
|
||||
let filename = format!("x{i:02x}");
|
||||
let contents = file_read(&at, &filename);
|
||||
assert_eq!(contents, "a");
|
||||
}
|
||||
|
|
|
@ -53,8 +53,8 @@ fn test_terse_normal_format() {
|
|||
let ts = TestScenario::new(util_name!());
|
||||
let actual = ts.ucmd().args(&args).succeeds().stdout_move_str();
|
||||
let expect = unwrap_or_return!(expected_result(&ts, &args)).stdout_move_str();
|
||||
println!("actual: {:?}", actual);
|
||||
println!("expect: {:?}", expect);
|
||||
println!("actual: {actual:?}");
|
||||
println!("expect: {expect:?}");
|
||||
let v_actual: Vec<&str> = actual.trim().split(' ').collect();
|
||||
let mut v_expect: Vec<&str> = expect.trim().split(' ').collect();
|
||||
assert!(!v_expect.is_empty());
|
||||
|
@ -83,8 +83,8 @@ fn test_format_created_time() {
|
|||
let ts = TestScenario::new(util_name!());
|
||||
let actual = ts.ucmd().args(&args).succeeds().stdout_move_str();
|
||||
let expect = unwrap_or_return!(expected_result(&ts, &args)).stdout_move_str();
|
||||
println!("actual: {:?}", actual);
|
||||
println!("expect: {:?}", expect);
|
||||
println!("actual: {actual:?}");
|
||||
println!("expect: {expect:?}");
|
||||
// note: using a regex instead of `split_whitespace()` in order to detect whitespace differences
|
||||
let re = regex::Regex::new(r"\s").unwrap();
|
||||
let v_actual: Vec<&str> = re.split(&actual).collect();
|
||||
|
@ -108,8 +108,8 @@ fn test_format_created_seconds() {
|
|||
let ts = TestScenario::new(util_name!());
|
||||
let actual = ts.ucmd().args(&args).succeeds().stdout_move_str();
|
||||
let expect = unwrap_or_return!(expected_result(&ts, &args)).stdout_move_str();
|
||||
println!("actual: {:?}", actual);
|
||||
println!("expect: {:?}", expect);
|
||||
println!("actual: {actual:?}");
|
||||
println!("expect: {expect:?}");
|
||||
// note: using a regex instead of `split_whitespace()` in order to detect whitespace differences
|
||||
let re = regex::Regex::new(r"\s").unwrap();
|
||||
let v_actual: Vec<&str> = re.split(&actual).collect();
|
||||
|
|
|
@ -621,8 +621,7 @@ fn test_follow_invalid_pid() {
|
|||
.fails()
|
||||
.no_stdout()
|
||||
.stderr_is(format!(
|
||||
"tail: invalid PID: '{}': number too large to fit in target type\n",
|
||||
max_pid
|
||||
"tail: invalid PID: '{max_pid}': number too large to fit in target type\n"
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -649,7 +648,7 @@ fn test_follow_with_pid() {
|
|||
|
||||
let mut child = ucmd
|
||||
.arg("-f")
|
||||
.arg(format!("--pid={}", pid))
|
||||
.arg(format!("--pid={pid}"))
|
||||
.arg(FOOBAR_TXT)
|
||||
.arg(FOOBAR_2_TXT)
|
||||
.run_no_wait();
|
||||
|
@ -706,17 +705,17 @@ fn test_single_big_args() {
|
|||
|
||||
let mut big_input = at.make_file(FILE);
|
||||
for i in 0..LINES {
|
||||
writeln!(big_input, "Line {}", i).expect("Could not write to FILE");
|
||||
writeln!(big_input, "Line {i}").expect("Could not write to FILE");
|
||||
}
|
||||
big_input.flush().expect("Could not flush FILE");
|
||||
|
||||
let mut big_expected = at.make_file(EXPECTED_FILE);
|
||||
for i in (LINES - N_ARG)..LINES {
|
||||
writeln!(big_expected, "Line {}", i).expect("Could not write to EXPECTED_FILE");
|
||||
writeln!(big_expected, "Line {i}").expect("Could not write to EXPECTED_FILE");
|
||||
}
|
||||
big_expected.flush().expect("Could not flush EXPECTED_FILE");
|
||||
|
||||
ucmd.arg(FILE).arg("-n").arg(format!("{}", N_ARG)).run();
|
||||
ucmd.arg(FILE).arg("-n").arg(format!("{N_ARG}")).run();
|
||||
// .stdout_is(at.read(EXPECTED_FILE));
|
||||
}
|
||||
|
||||
|
@ -753,21 +752,21 @@ fn test_bytes_big() {
|
|||
let mut big_input = at.make_file(FILE);
|
||||
for i in 0..BYTES {
|
||||
let digit = from_digit((i % 10) as u32, 10).unwrap();
|
||||
write!(big_input, "{}", digit).expect("Could not write to FILE");
|
||||
write!(big_input, "{digit}").expect("Could not write to FILE");
|
||||
}
|
||||
big_input.flush().expect("Could not flush FILE");
|
||||
|
||||
let mut big_expected = at.make_file(EXPECTED_FILE);
|
||||
for i in (BYTES - N_ARG)..BYTES {
|
||||
let digit = from_digit((i % 10) as u32, 10).unwrap();
|
||||
write!(big_expected, "{}", digit).expect("Could not write to EXPECTED_FILE");
|
||||
write!(big_expected, "{digit}").expect("Could not write to EXPECTED_FILE");
|
||||
}
|
||||
big_expected.flush().expect("Could not flush EXPECTED_FILE");
|
||||
|
||||
let result = ucmd
|
||||
.arg(FILE)
|
||||
.arg("-c")
|
||||
.arg(format!("{}", N_ARG))
|
||||
.arg(format!("{N_ARG}"))
|
||||
.succeeds()
|
||||
.stdout_move_str();
|
||||
let expected = at.read(EXPECTED_FILE);
|
||||
|
@ -789,13 +788,13 @@ fn test_lines_with_size_suffix() {
|
|||
|
||||
let mut big_input = at.make_file(FILE);
|
||||
for i in 0..LINES {
|
||||
writeln!(big_input, "Line {}", i).expect("Could not write to FILE");
|
||||
writeln!(big_input, "Line {i}").expect("Could not write to FILE");
|
||||
}
|
||||
big_input.flush().expect("Could not flush FILE");
|
||||
|
||||
let mut big_expected = at.make_file(EXPECTED_FILE);
|
||||
for i in (LINES - N_ARG)..LINES {
|
||||
writeln!(big_expected, "Line {}", i).expect("Could not write to EXPECTED_FILE");
|
||||
writeln!(big_expected, "Line {i}").expect("Could not write to EXPECTED_FILE");
|
||||
}
|
||||
big_expected.flush().expect("Could not flush EXPECTED_FILE");
|
||||
|
||||
|
@ -1549,13 +1548,12 @@ fn test_retry9() {
|
|||
"\
|
||||
tail: 'parent_dir/watched_file' has become inaccessible: No such file or directory\n\
|
||||
tail: directory containing watched file was removed\n\
|
||||
tail: {} cannot be used, reverting to polling\n\
|
||||
tail: {BACKEND} cannot be used, reverting to polling\n\
|
||||
tail: 'parent_dir/watched_file' has appeared; following new file\n\
|
||||
tail: 'parent_dir/watched_file' has become inaccessible: No such file or directory\n\
|
||||
tail: 'parent_dir/watched_file' has appeared; following new file\n\
|
||||
tail: 'parent_dir/watched_file' has become inaccessible: No such file or directory\n\
|
||||
tail: 'parent_dir/watched_file' has appeared; following new file\n",
|
||||
BACKEND
|
||||
tail: 'parent_dir/watched_file' has appeared; following new file\n"
|
||||
);
|
||||
let expected_stdout = "foo\nbar\nfoo\nbar\n";
|
||||
|
||||
|
@ -2281,9 +2279,8 @@ fn test_follow_name_move2() {
|
|||
let file2 = "file2";
|
||||
|
||||
let expected_stdout = format!(
|
||||
"==> {0} <==\n{0}_content\n\n==> {1} <==\n{1}_content\n{0}_content\n\
|
||||
more_{1}_content\n\n==> {0} <==\nmore_{0}_content\n",
|
||||
file1, file2
|
||||
"==> {file1} <==\n{file1}_content\n\n==> {file2} <==\n{file2}_content\n{file1}_content\n\
|
||||
more_{file2}_content\n\n==> {file1} <==\nmore_{file1}_content\n"
|
||||
);
|
||||
let mut expected_stderr = format!(
|
||||
"{0}: {1}: No such file or directory\n\
|
||||
|
@ -2438,9 +2435,8 @@ fn test_follow_name_move_retry2() {
|
|||
let file2 = "b";
|
||||
|
||||
let expected_stdout = format!(
|
||||
"==> {0} <==\n\n==> {1} <==\n\n==> {0} <==\nx\n\n==> {1} <==\
|
||||
\nx\n\n==> {0} <==\nx2\n\n==> {1} <==\ny\n\n==> {0} <==\nz\n",
|
||||
file1, file2
|
||||
"==> {file1} <==\n\n==> {file2} <==\n\n==> {file1} <==\nx\n\n==> {file2} <==\
|
||||
\nx\n\n==> {file1} <==\nx2\n\n==> {file2} <==\ny\n\n==> {file1} <==\nz\n"
|
||||
);
|
||||
let mut expected_stderr = format!(
|
||||
"{0}: '{1}' has become inaccessible: No such file or directory\n\
|
||||
|
@ -3851,8 +3847,7 @@ fn test_args_when_settings_check_warnings_then_shows_warnings() {
|
|||
|
||||
let expected_stdout = format!(
|
||||
"tail: warning: --retry ignored; --retry is useful only when following\n\
|
||||
{}",
|
||||
file_data
|
||||
{file_data}"
|
||||
);
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -3864,8 +3859,7 @@ fn test_args_when_settings_check_warnings_then_shows_warnings() {
|
|||
|
||||
let expected_stdout = format!(
|
||||
"tail: warning: --retry only effective for the initial open\n\
|
||||
{}",
|
||||
file_data
|
||||
{file_data}"
|
||||
);
|
||||
let mut child = scene
|
||||
.ucmd()
|
||||
|
@ -3882,8 +3876,7 @@ fn test_args_when_settings_check_warnings_then_shows_warnings() {
|
|||
|
||||
let expected_stdout = format!(
|
||||
"tail: warning: PID ignored; --pid=PID is useful only when following\n\
|
||||
{}",
|
||||
file_data
|
||||
{file_data}"
|
||||
);
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -3896,8 +3889,7 @@ fn test_args_when_settings_check_warnings_then_shows_warnings() {
|
|||
let expected_stdout = format!(
|
||||
"tail: warning: --retry ignored; --retry is useful only when following\n\
|
||||
tail: warning: PID ignored; --pid=PID is useful only when following\n\
|
||||
{}",
|
||||
file_data
|
||||
{file_data}"
|
||||
);
|
||||
scene
|
||||
.ucmd()
|
||||
|
@ -3963,9 +3955,8 @@ fn test_args_when_settings_check_warnings_follow_indefinitely_then_warning() {
|
|||
let expected_stdout = format!(
|
||||
"tail: warning: following standard input indefinitely is ineffective\n\
|
||||
==> data <==\n\
|
||||
{}\n\
|
||||
==> standard input <==\n",
|
||||
file_data
|
||||
{file_data}\n\
|
||||
==> standard input <==\n"
|
||||
);
|
||||
// tail -f data - < /dev/ptmx
|
||||
let mut child = scene
|
||||
|
@ -4055,10 +4046,9 @@ fn test_args_when_settings_check_warnings_follow_indefinitely_then_no_warning()
|
|||
let pipe_data = "pipe data";
|
||||
let expected_stdout = format!(
|
||||
"==> standard input <==\n\
|
||||
{}\n\
|
||||
==> {} <==\n\
|
||||
{}",
|
||||
pipe_data, file_name, file_data
|
||||
{pipe_data}\n\
|
||||
==> {file_name} <==\n\
|
||||
{file_data}"
|
||||
);
|
||||
let mut child = scene
|
||||
.ucmd()
|
||||
|
@ -4087,10 +4077,9 @@ fn test_args_when_settings_check_warnings_follow_indefinitely_then_no_warning()
|
|||
{
|
||||
let expected_stdout = format!(
|
||||
"==> standard input <==\n\
|
||||
{}\n\
|
||||
==> {} <==\n\
|
||||
{}",
|
||||
fifo_data, file_name, file_data
|
||||
{fifo_data}\n\
|
||||
==> {file_name} <==\n\
|
||||
{file_data}"
|
||||
);
|
||||
let mut child = scene
|
||||
.ucmd()
|
||||
|
@ -4108,10 +4097,9 @@ fn test_args_when_settings_check_warnings_follow_indefinitely_then_no_warning()
|
|||
|
||||
let expected_stdout = format!(
|
||||
"==> standard input <==\n\
|
||||
{}\n\
|
||||
==> {} <==\n\
|
||||
{}",
|
||||
fifo_data, file_name, file_data
|
||||
{fifo_data}\n\
|
||||
==> {file_name} <==\n\
|
||||
{file_data}"
|
||||
);
|
||||
let mut child = scene
|
||||
.ucmd()
|
||||
|
|
|
@ -70,7 +70,7 @@ fn test_tee_append() {
|
|||
fn test_tee_no_more_writeable_1() {
|
||||
// equals to 'tee /dev/full out2 <multi_read' call
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let content = (1..=10).map(|x| format!("{}\n", x)).collect::<String>();
|
||||
let content = (1..=10).map(|x| format!("{x}\n")).collect::<String>();
|
||||
let file_out = "tee_file_out";
|
||||
|
||||
ucmd.arg("/dev/full")
|
||||
|
@ -90,7 +90,7 @@ fn test_tee_no_more_writeable_2() {
|
|||
// but currently there is no way to redirect stdout to /dev/full
|
||||
// so this test is disabled
|
||||
let (_at, mut ucmd) = at_and_ucmd!();
|
||||
let _content = (1..=10).map(|x| format!("{}\n", x)).collect::<String>();
|
||||
let _content = (1..=10).map(|x| format!("{x}\n")).collect::<String>();
|
||||
let file_out_a = "tee_file_out_a";
|
||||
let file_out_b = "tee_file_out_b";
|
||||
|
||||
|
@ -130,7 +130,7 @@ mod linux_only {
|
|||
}
|
||||
|
||||
fn run_tee(proc: &mut UCommand) -> (String, Output) {
|
||||
let content = (1..=100000).map(|x| format!("{}\n", x)).collect::<String>();
|
||||
let content = (1..=100000).map(|x| format!("{x}\n")).collect::<String>();
|
||||
|
||||
#[allow(deprecated)]
|
||||
let output = proc
|
||||
|
@ -204,9 +204,7 @@ mod linux_only {
|
|||
contents.len()
|
||||
);
|
||||
assert!(contents.starts_with(&compare),
|
||||
"Expected truncated output to be a prefix of the correct output, but it isn't.\n Correct: {}\n Compare: {}",
|
||||
contents,
|
||||
compare);
|
||||
"Expected truncated output to be a prefix of the correct output, but it isn't.\n Correct: {contents}\n Compare: {compare}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -52,7 +52,7 @@ fn str_to_filetime(format: &str, s: &str) -> FileTime {
|
|||
let d = match time::OffsetDateTime::now_local() {
|
||||
Ok(now) => now,
|
||||
Err(e) => {
|
||||
panic!("Error {} retrieving the OffsetDateTime::now_local", e);
|
||||
panic!("Error {e} retrieving the OffsetDateTime::now_local");
|
||||
}
|
||||
};
|
||||
let offset_dt = tm.assume_offset(d.offset());
|
||||
|
@ -654,7 +654,7 @@ fn get_dst_switch_hour() -> Option<String> {
|
|||
let now = match time::OffsetDateTime::now_local() {
|
||||
Ok(now) => now,
|
||||
Err(e) => {
|
||||
panic!("Error {} retrieving the OffsetDateTime::now_local", e);
|
||||
panic!("Error {e} retrieving the OffsetDateTime::now_local");
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -712,8 +712,7 @@ fn test_touch_no_such_file_error_msg() {
|
|||
let path_str = path.to_str().unwrap();
|
||||
|
||||
new_ucmd!().arg(&path).fails().stderr_only(format!(
|
||||
"touch: cannot touch '{}': No such file or directory\n",
|
||||
path_str
|
||||
"touch: cannot touch '{path_str}': No such file or directory\n"
|
||||
));
|
||||
}
|
||||
|
||||
|
|
|
@ -19,13 +19,8 @@ fn test_increase_file_size() {
|
|||
ucmd.args(&["-s", "+5K", FILE1]).succeeds();
|
||||
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.seek(SeekFrom::Current(0)).unwrap();
|
||||
assert!(
|
||||
expected == actual,
|
||||
"expected '{}' got '{}'",
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -36,13 +31,8 @@ fn test_increase_file_size_kb() {
|
|||
ucmd.args(&["-s", "+5KB", FILE1]).succeeds();
|
||||
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.seek(SeekFrom::Current(0)).unwrap();
|
||||
assert!(
|
||||
expected == actual,
|
||||
"expected '{}' got '{}'",
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -66,13 +56,8 @@ fn test_reference() {
|
|||
.succeeds();
|
||||
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.seek(SeekFrom::Current(0)).unwrap();
|
||||
assert!(
|
||||
expected == actual,
|
||||
"expected '{}' got '{}'",
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -83,13 +68,8 @@ fn test_decrease_file_size() {
|
|||
file.write_all(b"1234567890").unwrap();
|
||||
ucmd.args(&["--size=-4", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.seek(SeekFrom::Current(0)).unwrap();
|
||||
assert!(
|
||||
expected == actual,
|
||||
"expected '{}' got '{}'",
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -100,13 +80,8 @@ fn test_space_in_size() {
|
|||
file.write_all(b"1234567890").unwrap();
|
||||
ucmd.args(&["--size", " 4", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.seek(SeekFrom::Current(0)).unwrap();
|
||||
assert!(
|
||||
expected == actual,
|
||||
"expected '{}' got '{}'",
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -134,13 +109,8 @@ fn test_at_most_shrinks() {
|
|||
file.write_all(b"1234567890").unwrap();
|
||||
ucmd.args(&["--size", "<4", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.seek(SeekFrom::Current(0)).unwrap();
|
||||
assert!(
|
||||
expected == actual,
|
||||
"expected '{}' got '{}'",
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -151,13 +121,8 @@ fn test_at_most_no_change() {
|
|||
file.write_all(b"1234567890").unwrap();
|
||||
ucmd.args(&["--size", "<40", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.seek(SeekFrom::Current(0)).unwrap();
|
||||
assert!(
|
||||
expected == actual,
|
||||
"expected '{}' got '{}'",
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -168,13 +133,8 @@ fn test_at_least_grows() {
|
|||
file.write_all(b"1234567890").unwrap();
|
||||
ucmd.args(&["--size", ">15", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.seek(SeekFrom::Current(0)).unwrap();
|
||||
assert!(
|
||||
expected == actual,
|
||||
"expected '{}' got '{}'",
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -185,13 +145,8 @@ fn test_at_least_no_change() {
|
|||
file.write_all(b"1234567890").unwrap();
|
||||
ucmd.args(&["--size", ">4", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.seek(SeekFrom::Current(0)).unwrap();
|
||||
assert!(
|
||||
expected == actual,
|
||||
"expected '{}' got '{}'",
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -202,13 +157,8 @@ fn test_round_down() {
|
|||
file.write_all(b"1234567890").unwrap();
|
||||
ucmd.args(&["--size", "/4", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.seek(SeekFrom::Current(0)).unwrap();
|
||||
assert!(
|
||||
expected == actual,
|
||||
"expected '{}' got '{}'",
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -219,13 +169,8 @@ fn test_round_up() {
|
|||
file.write_all(b"1234567890").unwrap();
|
||||
ucmd.args(&["--size", "%4", FILE2]).succeeds();
|
||||
file.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file.seek(SeekFrom::Current(0)).unwrap();
|
||||
assert!(
|
||||
expected == actual,
|
||||
"expected '{}' got '{}'",
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
let actual = file.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -238,13 +183,8 @@ fn test_size_and_reference() {
|
|||
ucmd.args(&["--reference", FILE1, "--size", "+5", FILE2])
|
||||
.succeeds();
|
||||
file2.seek(SeekFrom::End(0)).unwrap();
|
||||
let actual = file2.seek(SeekFrom::Current(0)).unwrap();
|
||||
assert!(
|
||||
expected == actual,
|
||||
"expected '{}' got '{}'",
|
||||
expected,
|
||||
actual
|
||||
);
|
||||
let actual = file2.stream_position().unwrap();
|
||||
assert!(expected == actual, "expected '{expected}' got '{actual}'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -26,7 +26,7 @@ fn test_count_bytes_large_stdin() {
|
|||
128 * 1024,
|
||||
] {
|
||||
let data = vec_of_size(n);
|
||||
let expected = format!("{}\n", n);
|
||||
let expected = format!("{n}\n");
|
||||
new_ucmd!()
|
||||
.args(&["-c"])
|
||||
.pipe_in(data)
|
||||
|
|
|
@ -44,8 +44,8 @@ fn test_heading() {
|
|||
// specifically number of TABs between "TIME" and "COMMENT" may be variant
|
||||
let actual = ts.ucmd().arg(opt).succeeds().stdout_move_str();
|
||||
let expect = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
||||
println!("actual: {:?}", actual);
|
||||
println!("expect: {:?}", expect);
|
||||
println!("actual: {actual:?}");
|
||||
println!("expect: {expect:?}");
|
||||
let v_actual: Vec<&str> = actual.split_whitespace().collect();
|
||||
let v_expect: Vec<&str> = expect.split_whitespace().collect();
|
||||
assert_eq!(v_actual, v_expect);
|
||||
|
@ -165,8 +165,8 @@ fn test_users() {
|
|||
for opt in ["-u", "--users", "--us"] {
|
||||
let actual = ts.ucmd().arg(opt).succeeds().stdout_move_str();
|
||||
let expect = unwrap_or_return!(expected_result(&ts, &[opt])).stdout_move_str();
|
||||
println!("actual: {:?}", actual);
|
||||
println!("expect: {:?}", expect);
|
||||
println!("actual: {actual:?}");
|
||||
println!("expect: {expect:?}");
|
||||
|
||||
let mut v_actual: Vec<&str> = actual.split_whitespace().collect();
|
||||
let mut v_expect: Vec<&str> = expect.split_whitespace().collect();
|
||||
|
|
|
@ -43,7 +43,7 @@ fn test_normal_compare_env() {
|
|||
if whoami == "nobody" {
|
||||
println!("test skipped:");
|
||||
} else if !is_ci() {
|
||||
new_ucmd!().succeeds().stdout_is(format!("{}\n", whoami));
|
||||
new_ucmd!().succeeds().stdout_is(format!("{whoami}\n"));
|
||||
} else {
|
||||
println!("test skipped:");
|
||||
}
|
||||
|
|
|
@ -293,7 +293,7 @@ impl CmdResult {
|
|||
pub fn signal_name_is(&self, name: &str) -> &Self {
|
||||
use uucore::signals::signal_by_name_or_value;
|
||||
let expected: i32 = signal_by_name_or_value(name)
|
||||
.unwrap_or_else(|| panic!("Invalid signal name or value: '{}'", name))
|
||||
.unwrap_or_else(|| panic!("Invalid signal name or value: '{name}'"))
|
||||
.try_into()
|
||||
.unwrap();
|
||||
|
||||
|
@ -2223,7 +2223,7 @@ pub fn host_name_for(util_name: &str) -> Cow<str> {
|
|||
if util_name.starts_with('g') && util_name != "groups" {
|
||||
util_name.into()
|
||||
} else {
|
||||
format!("g{}", util_name).into()
|
||||
format!("g{util_name}").into()
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
|
@ -3146,10 +3146,7 @@ mod tests {
|
|||
Err(error) if error.kind() == io::ErrorKind::Other => {
|
||||
std::assert_eq!(error.to_string(), "wait: Timeout of '1s' reached");
|
||||
}
|
||||
Err(error) => panic!(
|
||||
"Assertion failed: Expected error with timeout but was: {}",
|
||||
error
|
||||
),
|
||||
Err(error) => panic!("Assertion failed: Expected error with timeout but was: {error}"),
|
||||
Ok(_) => panic!("Assertion failed: Expected timeout of `wait`."),
|
||||
}
|
||||
}
|
||||
|
@ -3178,10 +3175,7 @@ mod tests {
|
|||
Err(error) if error.kind() == io::ErrorKind::Other => {
|
||||
std::assert_eq!(error.to_string(), "kill: Timeout of '0s' reached");
|
||||
}
|
||||
Err(error) => panic!(
|
||||
"Assertion failed: Expected error with timeout but was: {}",
|
||||
error
|
||||
),
|
||||
Err(error) => panic!("Assertion failed: Expected error with timeout but was: {error}"),
|
||||
Ok(_) => panic!("Assertion failed: Expected timeout of `try_kill`."),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue