1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #8084 from cakebaker/rm_consistent_naming_test_fns

rm: consistent naming of test functions
This commit is contained in:
Sylvestre Ledru 2025-06-07 11:28:24 +02:00 committed by GitHub
commit 6ebe611d12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,10 +6,8 @@
use std::process::Stdio; use std::process::Stdio;
use uutests::at_and_ucmd;
use uutests::new_ucmd;
use uutests::util::TestScenario; use uutests::util::TestScenario;
use uutests::util_name; use uutests::{at_and_ucmd, new_ucmd, util_name};
#[test] #[test]
fn test_invalid_arg() { fn test_invalid_arg() {
@ -17,7 +15,7 @@ fn test_invalid_arg() {
} }
#[test] #[test]
fn test_rm_one_file() { fn test_one_file() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let file = "test_rm_one_file"; let file = "test_rm_one_file";
@ -29,17 +27,17 @@ fn test_rm_one_file() {
} }
#[test] #[test]
fn test_rm_failed() { fn test_failed() {
let (_at, mut ucmd) = at_and_ucmd!();
let file = "test_rm_one_file"; // Doesn't exist let file = "test_rm_one_file"; // Doesn't exist
ucmd.arg(file) new_ucmd!()
.arg(file)
.fails() .fails()
.stderr_contains(format!("cannot remove '{file}': No such file or directory")); .stderr_contains(format!("cannot remove '{file}': No such file or directory"));
} }
#[test] #[test]
fn test_rm_multiple_files() { fn test_multiple_files() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let file_a = "test_rm_multiple_file_a"; let file_a = "test_rm_multiple_file_a";
let file_b = "test_rm_multiple_file_b"; let file_b = "test_rm_multiple_file_b";
@ -54,7 +52,7 @@ fn test_rm_multiple_files() {
} }
#[test] #[test]
fn test_rm_interactive() { fn test_interactive() {
let scene = TestScenario::new(util_name!()); let scene = TestScenario::new(util_name!());
let at = &scene.fixtures; let at = &scene.fixtures;
@ -90,7 +88,7 @@ fn test_rm_interactive() {
} }
#[test] #[test]
fn test_rm_force() { fn test_force() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let file_a = "test_rm_force_a"; let file_a = "test_rm_force_a";
let file_b = "test_rm_force_b"; let file_b = "test_rm_force_b";
@ -111,7 +109,7 @@ fn test_rm_force() {
} }
#[test] #[test]
fn test_rm_force_multiple() { fn test_force_multiple() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let file_a = "test_rm_force_a"; let file_a = "test_rm_force_a";
let file_b = "test_rm_force_b"; let file_b = "test_rm_force_b";
@ -134,7 +132,7 @@ fn test_rm_force_multiple() {
} }
#[test] #[test]
fn test_rm_empty_directory() { fn test_empty_directory() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let dir = "test_rm_empty_directory"; let dir = "test_rm_empty_directory";
@ -146,7 +144,7 @@ fn test_rm_empty_directory() {
} }
#[test] #[test]
fn test_rm_empty_directory_verbose() { fn test_empty_directory_verbose() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let dir = "test_rm_empty_directory_verbose"; let dir = "test_rm_empty_directory_verbose";
@ -162,7 +160,7 @@ fn test_rm_empty_directory_verbose() {
} }
#[test] #[test]
fn test_rm_non_empty_directory() { fn test_non_empty_directory() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let dir = "test_rm_non_empty_dir"; let dir = "test_rm_non_empty_dir";
let file_a = &format!("{dir}/test_rm_non_empty_file_a"); let file_a = &format!("{dir}/test_rm_non_empty_file_a");
@ -180,7 +178,7 @@ fn test_rm_non_empty_directory() {
} }
#[test] #[test]
fn test_rm_recursive() { fn test_recursive() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let dir = "test_rm_recursive_directory"; let dir = "test_rm_recursive_directory";
let file_a = "test_rm_recursive_directory/test_rm_recursive_file_a"; let file_a = "test_rm_recursive_directory/test_rm_recursive_file_a";
@ -198,7 +196,7 @@ fn test_rm_recursive() {
} }
#[test] #[test]
fn test_rm_recursive_multiple() { fn test_recursive_multiple() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let dir = "test_rm_recursive_directory"; let dir = "test_rm_recursive_directory";
let file_a = "test_rm_recursive_directory/test_rm_recursive_file_a"; let file_a = "test_rm_recursive_directory/test_rm_recursive_file_a";
@ -221,7 +219,7 @@ fn test_rm_recursive_multiple() {
} }
#[test] #[test]
fn test_rm_directory_without_flag() { fn test_directory_without_flag() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let dir = "test_rm_directory_without_flag_dir"; let dir = "test_rm_directory_without_flag_dir";
@ -235,7 +233,7 @@ fn test_rm_directory_without_flag() {
#[test] #[test]
#[cfg(windows)] #[cfg(windows)]
// https://github.com/uutils/coreutils/issues/3200 // https://github.com/uutils/coreutils/issues/3200
fn test_rm_directory_with_trailing_backslash() { fn test_directory_with_trailing_backslash() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let dir = "dir"; let dir = "dir";
@ -246,7 +244,7 @@ fn test_rm_directory_with_trailing_backslash() {
} }
#[test] #[test]
fn test_rm_verbose() { fn test_verbose() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let file_a = "test_rm_verbose_file_a"; let file_a = "test_rm_verbose_file_a";
let file_b = "test_rm_verbose_file_b"; let file_b = "test_rm_verbose_file_b";
@ -264,7 +262,7 @@ fn test_rm_verbose() {
#[test] #[test]
#[cfg(not(windows))] #[cfg(not(windows))]
// on unix symlink_dir is a file // on unix symlink_dir is a file
fn test_rm_symlink_dir() { fn test_symlink_dir() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let dir = "test_rm_symlink_dir_directory"; let dir = "test_rm_symlink_dir_directory";
@ -279,7 +277,7 @@ fn test_rm_symlink_dir() {
#[test] #[test]
#[cfg(windows)] #[cfg(windows)]
// on windows removing symlink_dir requires "-r" or "-d" // on windows removing symlink_dir requires "-r" or "-d"
fn test_rm_symlink_dir() { fn test_symlink_dir() {
let scene = TestScenario::new(util_name!()); let scene = TestScenario::new(util_name!());
let at = &scene.fixtures; let at = &scene.fixtures;
@ -301,7 +299,7 @@ fn test_rm_symlink_dir() {
} }
#[test] #[test]
fn test_rm_invalid_symlink() { fn test_invalid_symlink() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let link = "test_rm_invalid_symlink"; let link = "test_rm_invalid_symlink";
@ -311,20 +309,17 @@ fn test_rm_invalid_symlink() {
} }
#[test] #[test]
fn test_rm_force_no_operand() { fn test_force_no_operand() {
let mut ucmd = new_ucmd!(); new_ucmd!().arg("-f").succeeds().no_stderr();
ucmd.arg("-f").succeeds().no_stderr();
} }
#[test] #[test]
fn test_rm_no_operand() { fn test_no_operand() {
let ts = TestScenario::new(util_name!()); new_ucmd!().fails().usage_error("missing operand");
ts.ucmd().fails().usage_error("missing operand");
} }
#[test] #[test]
fn test_rm_verbose_slash() { fn test_verbose_slash() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let dir = "test_rm_verbose_slash_directory"; let dir = "test_rm_verbose_slash_directory";
let file_a = &format!("{dir}/test_rm_verbose_slash_file_a"); let file_a = &format!("{dir}/test_rm_verbose_slash_file_a");
@ -351,7 +346,7 @@ fn test_rm_verbose_slash() {
} }
#[test] #[test]
fn test_rm_silently_accepts_presume_input_tty2() { fn test_silently_accepts_presume_input_tty2() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let file_2 = "test_rm_silently_accepts_presume_input_tty2"; let file_2 = "test_rm_silently_accepts_presume_input_tty2";
@ -363,7 +358,7 @@ fn test_rm_silently_accepts_presume_input_tty2() {
} }
#[test] #[test]
fn test_rm_interactive_never() { fn test_interactive_never() {
let scene = TestScenario::new(util_name!()); let scene = TestScenario::new(util_name!());
let at = &scene.fixtures; let at = &scene.fixtures;
@ -384,7 +379,7 @@ fn test_rm_interactive_never() {
} }
#[test] #[test]
fn test_rm_interactive_missing_value() { fn test_interactive_missing_value() {
// `--interactive` is equivalent to `--interactive=always` or `-i` // `--interactive` is equivalent to `--interactive=always` or `-i`
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
@ -405,7 +400,7 @@ fn test_rm_interactive_missing_value() {
} }
#[test] #[test]
fn test_rm_interactive_once_prompt() { fn test_interactive_once_prompt() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let file1 = "test_rm_interactive_once_recursive_prompt_file1"; let file1 = "test_rm_interactive_once_recursive_prompt_file1";
@ -434,7 +429,7 @@ fn test_rm_interactive_once_prompt() {
} }
#[test] #[test]
fn test_rm_interactive_once_recursive_prompt() { fn test_interactive_once_recursive_prompt() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
let file1 = "test_rm_interactive_once_recursive_prompt_file1"; let file1 = "test_rm_interactive_once_recursive_prompt_file1";
@ -452,7 +447,7 @@ fn test_rm_interactive_once_recursive_prompt() {
} }
#[test] #[test]
fn test_rm_descend_directory() { fn test_descend_directory() {
// This test descends into each directory and deletes the files and folders inside of them // This test descends into each directory and deletes the files and folders inside of them
// This test will have the rm process asks 6 question and us answering Y to them will delete all the files and folders // This test will have the rm process asks 6 question and us answering Y to them will delete all the files and folders
@ -494,7 +489,7 @@ fn test_rm_descend_directory() {
#[cfg(feature = "chmod")] #[cfg(feature = "chmod")]
#[test] #[test]
fn test_rm_prompts() { fn test_prompts() {
use std::io::Write; use std::io::Write;
// Needed for talking with stdin on platforms where CRLF or LF matters // Needed for talking with stdin on platforms where CRLF or LF matters
@ -581,7 +576,7 @@ fn test_rm_prompts() {
#[cfg(feature = "chmod")] #[cfg(feature = "chmod")]
#[test] #[test]
fn test_rm_prompts_no_tty() { fn test_prompts_no_tty() {
// This test ensures InteractiveMode.PromptProtected proceeds silently with non-interactive stdin // This test ensures InteractiveMode.PromptProtected proceeds silently with non-interactive stdin
use std::io::Write; use std::io::Write;
@ -624,7 +619,7 @@ fn test_rm_prompts_no_tty() {
} }
#[test] #[test]
fn test_rm_force_prompts_order() { fn test_force_prompts_order() {
// Needed for talking with stdin on platforms where CRLF or LF matters // Needed for talking with stdin on platforms where CRLF or LF matters
const END_OF_LINE: &str = if cfg!(windows) { "\r\n" } else { "\n" }; const END_OF_LINE: &str = if cfg!(windows) { "\r\n" } else { "\n" };
@ -665,7 +660,7 @@ fn test_rm_force_prompts_order() {
#[test] #[test]
#[ignore = "issue #3722"] #[ignore = "issue #3722"]
fn test_rm_directory_rights_rm1() { fn test_directory_rights_rm1() {
let (at, mut ucmd) = at_and_ucmd!(); let (at, mut ucmd) = at_and_ucmd!();
at.mkdir_all("b/a/p"); at.mkdir_all("b/a/p");
at.mkdir_all("b/c"); at.mkdir_all("b/c");
@ -738,7 +733,7 @@ fn test_remove_inaccessible_dir() {
#[test] #[test]
#[cfg(not(windows))] #[cfg(not(windows))]
fn test_rm_current_or_parent_dir_rm4() { fn test_current_or_parent_dir_rm4() {
let ts = TestScenario::new(util_name!()); let ts = TestScenario::new(util_name!());
let at = &ts.fixtures; let at = &ts.fixtures;
@ -769,7 +764,7 @@ fn test_rm_current_or_parent_dir_rm4() {
#[test] #[test]
#[cfg(windows)] #[cfg(windows)]
fn test_rm_current_or_parent_dir_rm4_windows() { fn test_current_or_parent_dir_rm4_windows() {
let ts = TestScenario::new(util_name!()); let ts = TestScenario::new(util_name!());
let at = &ts.fixtures; let at = &ts.fixtures;