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

tests ~ refactor/polish spelling (comments, names, and exceptions)

This commit is contained in:
Roy Ivy III 2021-05-30 00:10:54 -05:00
parent 5c9b474cc8
commit 4e20dedf58
63 changed files with 368 additions and 302 deletions

View file

@ -21,7 +21,7 @@ struct TestCase {
after: u32,
}
fn mkfile(file: &str, mode: u32) {
fn make_file(file: &str, mode: u32) {
OpenOptions::new()
.mode(mode)
.create(true)
@ -34,7 +34,7 @@ fn mkfile(file: &str, mode: u32) {
}
fn run_single_test(test: &TestCase, at: AtPath, mut ucmd: UCommand) {
mkfile(&at.plus_as_string(TEST_FILE), test.before);
make_file(&at.plus_as_string(TEST_FILE), test.before);
let perms = at.metadata(TEST_FILE).permissions().mode();
if perms != test.before {
panic!(
@ -123,6 +123,7 @@ fn test_chmod_octal() {
#[test]
#[allow(clippy::unreadable_literal)]
// spell-checker:disable-next-line
fn test_chmod_ugoa() {
let _guard = UMASK_MUTEX.lock();
@ -283,7 +284,7 @@ fn test_chmod_reference_file() {
},
];
let (at, ucmd) = at_and_ucmd!();
mkfile(&at.plus_as_string(REFERENCE_FILE), REFERENCE_PERMS);
make_file(&at.plus_as_string(REFERENCE_FILE), REFERENCE_PERMS);
run_single_test(&tests[0], at, ucmd);
}
@ -318,10 +319,10 @@ fn test_chmod_recursive() {
at.mkdir("a/b");
at.mkdir("a/b/c");
at.mkdir("z");
mkfile(&at.plus_as_string("a/a"), 0o100444);
mkfile(&at.plus_as_string("a/b/b"), 0o100444);
mkfile(&at.plus_as_string("a/b/c/c"), 0o100444);
mkfile(&at.plus_as_string("z/y"), 0o100444);
make_file(&at.plus_as_string("a/a"), 0o100444);
make_file(&at.plus_as_string("a/b/b"), 0o100444);
make_file(&at.plus_as_string("a/b/c/c"), 0o100444);
make_file(&at.plus_as_string("z/y"), 0o100444);
ucmd.arg("-R")
.arg("--verbose")
@ -351,9 +352,9 @@ fn test_chmod_non_existing_file() {
.arg("-R")
.arg("--verbose")
.arg("-r,a+w")
.arg("dont-exist")
.arg("does-not-exist")
.fails()
.stderr_contains(&"cannot access 'dont-exist': No such file or directory");
.stderr_contains(&"cannot access 'does-not-exist': No such file or directory");
}
#[test]
@ -432,6 +433,7 @@ fn test_chmod_symlink_non_existing_file_recursive() {
.no_stdout();
let expected_stdout = &format!(
// spell-checker:disable-next-line
"mode of '{}' retained as 0755 (rwxr-xr-x)\nneither symbolic link '{}/{}' nor referent has been changed",
test_directory, test_directory, test_symlink
);
@ -473,8 +475,8 @@ fn test_chmod_strip_minus_from_mode() {
("chmod -c -R +w FILE ", "chmod -c -R +w FILE "),
("chmod a=r,=xX FILE", "chmod a=r,=xX FILE"),
(
"chmod -v --reference RFILE -R FILE",
"chmod -v --reference RFILE -R FILE",
"chmod -v --reference REF_FILE -R FILE",
"chmod -v --reference REF_FILE -R FILE",
),
("chmod -Rvc -w-x FILE", "chmod -Rvc w-x FILE"),
("chmod 755 -v FILE", "chmod 755 -v FILE"),