mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
Merge pull request #7371 from sylvestre/use-new-function
use the new function fails_with_code
This commit is contained in:
@@ -19,5 +19,5 @@ fn test_arch_help() {
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
@@ -192,14 +192,13 @@ fn test_simple_format() {
|
||||
new_ucmd!().args(&["a-z", "-z"]).succeeds().stdout_is("a\n");
|
||||
new_ucmd!()
|
||||
.args(&["a", "b", "c"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_contains("extra operand 'c'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -615,8 +615,7 @@ fn test_write_to_self() {
|
||||
.arg("first_file")
|
||||
.arg("first_file")
|
||||
.arg("second_file")
|
||||
.fails()
|
||||
.code_is(2)
|
||||
.fails_with_code(2)
|
||||
.stderr_only("cat: first_file: input file is output file\ncat: first_file: input file is output file\n");
|
||||
|
||||
assert_eq!(
|
||||
|
||||
@@ -14,7 +14,7 @@ fn test_invalid_option() {
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
static DIR: &str = "/dev";
|
||||
|
||||
+12
-19
@@ -266,8 +266,7 @@ fn test_chmod_error_permissions() {
|
||||
|
||||
ucmd.args(&["-w", "file"])
|
||||
.umask(0o022)
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_is(
|
||||
// spell-checker:disable-next-line
|
||||
"chmod: file: new permissions are r-xrwxrwx, not r-xr-xr-x\n",
|
||||
@@ -442,9 +441,8 @@ fn test_chmod_non_existing_file_silent() {
|
||||
.arg("--quiet")
|
||||
.arg("-r,a+w")
|
||||
.arg("does-not-exist")
|
||||
.fails()
|
||||
.no_stderr()
|
||||
.code_is(1);
|
||||
.fails_with_code(1)
|
||||
.no_stderr();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -454,7 +452,7 @@ fn test_chmod_preserve_root() {
|
||||
.arg("--preserve-root")
|
||||
.arg("755")
|
||||
.arg("/")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.stderr_contains("chmod: it is dangerous to operate recursively on '/'");
|
||||
}
|
||||
|
||||
@@ -478,8 +476,7 @@ fn test_chmod_symlink_non_existing_file() {
|
||||
.arg("755")
|
||||
.arg("-v")
|
||||
.arg(test_symlink)
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stdout_contains(expected_stdout)
|
||||
.stderr_contains(expected_stderr);
|
||||
|
||||
@@ -585,14 +582,13 @@ fn test_chmod_keep_setgid() {
|
||||
fn test_no_operands() {
|
||||
new_ucmd!()
|
||||
.arg("777")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.usage_error("missing operand");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -624,9 +620,8 @@ fn test_chmod_file_after_non_existing_file() {
|
||||
.arg("u+x")
|
||||
.arg("does-not-exist")
|
||||
.arg(TEST_FILE)
|
||||
.fails()
|
||||
.stderr_contains("chmod: cannot access 'does-not-exist': No such file or directory")
|
||||
.code_is(1);
|
||||
.fails_with_code(1)
|
||||
.stderr_contains("chmod: cannot access 'does-not-exist': No such file or directory");
|
||||
|
||||
assert_eq!(at.metadata(TEST_FILE).permissions().mode(), 0o100_764);
|
||||
|
||||
@@ -636,9 +631,8 @@ fn test_chmod_file_after_non_existing_file() {
|
||||
.arg("--q")
|
||||
.arg("does-not-exist")
|
||||
.arg("file2")
|
||||
.fails()
|
||||
.no_stderr()
|
||||
.code_is(1);
|
||||
.fails_with_code(1)
|
||||
.no_stderr();
|
||||
assert_eq!(at.metadata("file2").permissions().mode(), 0o100_764);
|
||||
}
|
||||
|
||||
@@ -669,8 +663,7 @@ fn test_chmod_file_symlink_after_non_existing_file() {
|
||||
.arg("-v")
|
||||
.arg(test_dangling_symlink)
|
||||
.arg(test_existing_symlink)
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stdout_contains(expected_stdout)
|
||||
.stderr_contains(expected_stderr);
|
||||
assert_eq!(
|
||||
|
||||
@@ -81,7 +81,7 @@ fn test_invalid_option() {
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -10,14 +10,12 @@ use crate::common::util::{run_ucmd_as_root, TestScenario};
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(125);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(125);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_missing_operand() {
|
||||
let result = new_ucmd!().fails();
|
||||
|
||||
result.code_is(125);
|
||||
let result = new_ucmd!().fails_with_code(125);
|
||||
|
||||
assert!(result
|
||||
.stderr_str()
|
||||
@@ -34,8 +32,7 @@ fn test_enter_chroot_fails() {
|
||||
|
||||
at.mkdir("jail");
|
||||
|
||||
let result = ucmd.arg("jail").fails();
|
||||
result.code_is(125);
|
||||
let result = ucmd.arg("jail").fails_with_code(125);
|
||||
assert!(result
|
||||
.stderr_str()
|
||||
.starts_with("chroot: cannot chroot to 'jail': Operation not permitted (os error 1)"));
|
||||
@@ -48,9 +45,8 @@ fn test_no_such_directory() {
|
||||
at.touch(at.plus_as_string("a"));
|
||||
|
||||
ucmd.arg("a")
|
||||
.fails()
|
||||
.stderr_is("chroot: cannot change root directory to 'a': no such directory\n")
|
||||
.code_is(125);
|
||||
.fails_with_code(125)
|
||||
.stderr_is("chroot: cannot change root directory to 'a': no such directory\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -160,9 +156,7 @@ fn test_preference_of_userspec() {
|
||||
.arg("--groups")
|
||||
.arg("ABC,DEF")
|
||||
.arg(format!("--userspec={username}:{group_name}"))
|
||||
.fails();
|
||||
|
||||
result.code_is(125);
|
||||
.fails_with_code(125);
|
||||
|
||||
println!("result.stdout = {}", result.stdout_str());
|
||||
println!("result.stderr = {}", result.stderr_str());
|
||||
@@ -216,9 +210,8 @@ fn test_chroot_skip_chdir_not_root() {
|
||||
|
||||
ucmd.arg("--skip-chdir")
|
||||
.arg(dir)
|
||||
.fails()
|
||||
.stderr_contains("chroot: option --skip-chdir only permitted if NEWROOT is old '/'")
|
||||
.code_is(125);
|
||||
.fails_with_code(125)
|
||||
.stderr_contains("chroot: option --skip-chdir only permitted if NEWROOT is old '/'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+29
-42
@@ -12,7 +12,7 @@ const ALGOS: [&str; 11] = [
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -75,7 +75,7 @@ fn test_nonexisting_file() {
|
||||
|
||||
new_ucmd!()
|
||||
.arg(file_name)
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains(format!("cksum: {file_name}: No such file or directory"));
|
||||
}
|
||||
@@ -301,32 +301,28 @@ fn test_check_algo() {
|
||||
.arg("lorem_ipsum.txt")
|
||||
.fails()
|
||||
.no_stdout()
|
||||
.stderr_contains("cksum: --check is not supported with --algorithm={bsd,sysv,crc,crc32b}")
|
||||
.code_is(1);
|
||||
.stderr_contains("cksum: --check is not supported with --algorithm={bsd,sysv,crc,crc32b}");
|
||||
new_ucmd!()
|
||||
.arg("-a=sysv")
|
||||
.arg("--check")
|
||||
.arg("lorem_ipsum.txt")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains("cksum: --check is not supported with --algorithm={bsd,sysv,crc,crc32b}")
|
||||
.code_is(1);
|
||||
.stderr_contains("cksum: --check is not supported with --algorithm={bsd,sysv,crc,crc32b}");
|
||||
new_ucmd!()
|
||||
.arg("-a=crc")
|
||||
.arg("--check")
|
||||
.arg("lorem_ipsum.txt")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains("cksum: --check is not supported with --algorithm={bsd,sysv,crc,crc32b}")
|
||||
.code_is(1);
|
||||
.stderr_contains("cksum: --check is not supported with --algorithm={bsd,sysv,crc,crc32b}");
|
||||
new_ucmd!()
|
||||
.arg("-a=crc32b")
|
||||
.arg("--check")
|
||||
.arg("lorem_ipsum.txt")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains("cksum: --check is not supported with --algorithm={bsd,sysv,crc,crc32b}")
|
||||
.code_is(1);
|
||||
.stderr_contains("cksum: --check is not supported with --algorithm={bsd,sysv,crc,crc32b}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -335,20 +331,18 @@ fn test_length_with_wrong_algorithm() {
|
||||
.arg("--length=16")
|
||||
.arg("--algorithm=md5")
|
||||
.arg("lorem_ipsum.txt")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains("cksum: --length is only supported with --algorithm=blake2b")
|
||||
.code_is(1);
|
||||
.stderr_contains("cksum: --length is only supported with --algorithm=blake2b");
|
||||
|
||||
new_ucmd!()
|
||||
.arg("--length=16")
|
||||
.arg("--algorithm=md5")
|
||||
.arg("-c")
|
||||
.arg("foo.sums")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains("cksum: --length is only supported with --algorithm=blake2b")
|
||||
.code_is(1);
|
||||
.stderr_contains("cksum: --length is only supported with --algorithm=blake2b");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -356,10 +350,9 @@ fn test_length_not_supported() {
|
||||
new_ucmd!()
|
||||
.arg("--length=15")
|
||||
.arg("lorem_ipsum.txt")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains("--length is only supported with --algorithm=blake2b")
|
||||
.code_is(1);
|
||||
.stderr_contains("--length is only supported with --algorithm=blake2b");
|
||||
|
||||
new_ucmd!()
|
||||
.arg("-l")
|
||||
@@ -368,10 +361,9 @@ fn test_length_not_supported() {
|
||||
.arg("-a")
|
||||
.arg("crc")
|
||||
.arg("/tmp/xxx")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains("--length is only supported with --algorithm=blake2b")
|
||||
.code_is(1);
|
||||
.stderr_contains("--length is only supported with --algorithm=blake2b");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -394,7 +386,7 @@ fn test_length_greater_than_512() {
|
||||
.arg("--algorithm=blake2b")
|
||||
.arg("lorem_ipsum.txt")
|
||||
.arg("alice_in_wonderland.txt")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_is_fixture("length_larger_than_512.expected");
|
||||
}
|
||||
@@ -443,10 +435,9 @@ fn test_raw_multiple_files() {
|
||||
.arg("--raw")
|
||||
.arg("lorem_ipsum.txt")
|
||||
.arg("alice_in_wonderland.txt")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains("cksum: the --raw option is not supported with multiple files")
|
||||
.code_is(1);
|
||||
.stderr_contains("cksum: the --raw option is not supported with multiple files");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -455,7 +446,7 @@ fn test_base64_raw_conflicts() {
|
||||
.arg("--base64")
|
||||
.arg("--raw")
|
||||
.arg("lorem_ipsum.txt")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains("--base64")
|
||||
.stderr_contains("cannot be used with")
|
||||
@@ -749,12 +740,11 @@ fn test_conflicting_options() {
|
||||
.arg("--binary")
|
||||
.arg("--check")
|
||||
.arg("f")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains(
|
||||
"cksum: the --binary and --text options are meaningless when verifying checksums",
|
||||
)
|
||||
.code_is(1);
|
||||
);
|
||||
|
||||
scene
|
||||
.ucmd()
|
||||
@@ -762,12 +752,11 @@ fn test_conflicting_options() {
|
||||
.arg("-c")
|
||||
.arg("-a")
|
||||
.arg("md5")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains(
|
||||
"cksum: the --binary and --text options are meaningless when verifying checksums",
|
||||
)
|
||||
.code_is(1);
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -784,10 +773,9 @@ fn test_check_algo_err() {
|
||||
.arg("sm3")
|
||||
.arg("--check")
|
||||
.arg("f")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains("cksum: f: no properly formatted checksum lines found")
|
||||
.code_is(1);
|
||||
.stderr_contains("cksum: f: no properly formatted checksum lines found");
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -803,10 +791,9 @@ fn test_check_pipe() {
|
||||
.arg("--check")
|
||||
.arg("-")
|
||||
.pipe_in("f")
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_contains("cksum: 'standard input': no properly formatted checksum lines found")
|
||||
.code_is(1);
|
||||
.stderr_contains("cksum: 'standard input': no properly formatted checksum lines found");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::common::util::TestScenario;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -459,8 +459,7 @@ fn test_sorted() {
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["comm1", "comm2"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stdout_is("1\n\t\t3\n\t2\n")
|
||||
.stderr_is(expected_stderr);
|
||||
}
|
||||
@@ -477,8 +476,7 @@ fn test_sorted_check_order() {
|
||||
.ucmd()
|
||||
.arg("--check-order")
|
||||
.args(&["comm1", "comm2"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stdout_is("1\n\t\t3\n")
|
||||
.stderr_is(expected_stderr);
|
||||
}
|
||||
@@ -493,8 +491,7 @@ fn test_both_inputs_out_of_order() {
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["file_a", "file_b"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stdout_is("\t\t3\n1\n0\n\t2\n\t0\n")
|
||||
.stderr_is(
|
||||
"comm: file 1 is not in sorted order\n\
|
||||
@@ -513,8 +510,7 @@ fn test_both_inputs_out_of_order_last_pair() {
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["file_a", "file_b"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stdout_is("\t\t3\n1\n\t2\n")
|
||||
.stderr_is(
|
||||
"comm: file 1 is not in sorted order\n\
|
||||
@@ -533,8 +529,7 @@ fn test_first_input_out_of_order_extended() {
|
||||
scene
|
||||
.ucmd()
|
||||
.args(&["file_a", "file_b"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stdout_is("0\n\t2\n\t\t3\n1\n")
|
||||
.stderr_is(
|
||||
"comm: file 1 is not in sorted order\n\
|
||||
|
||||
@@ -185,8 +185,7 @@ fn test_cp_same_file() {
|
||||
|
||||
ucmd.arg(file)
|
||||
.arg(file)
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_contains(format!("'{file}' and '{file}' are the same file"));
|
||||
}
|
||||
|
||||
@@ -664,8 +663,7 @@ fn test_cp_arg_interactive_update_overwrite_older() {
|
||||
at.touch("a");
|
||||
ucmd.args(&["-i", "-u", "a", "b"])
|
||||
.pipe_in("N\n")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.no_stdout()
|
||||
.stderr_is("cp: overwrite 'b'? ");
|
||||
|
||||
@@ -1720,8 +1718,7 @@ fn test_cp_preserve_invalid_rejected() {
|
||||
.arg("--preserve=invalid-value")
|
||||
.arg(TEST_COPY_FROM_FOLDER_FILE)
|
||||
.arg(TEST_HELLO_WORLD_DEST)
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.no_stdout();
|
||||
}
|
||||
|
||||
@@ -3465,8 +3462,7 @@ fn test_copy_dir_preserve_permissions_inaccessible_file() {
|
||||
// | | | |
|
||||
// V V V V
|
||||
ucmd.args(&["-p", "-R", "d1", "d2"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_only("cp: cannot open 'd1/f' for reading: permission denied\n");
|
||||
assert!(at.dir_exists("d2"));
|
||||
assert!(!at.file_exists("d2/f"));
|
||||
@@ -5979,16 +5975,14 @@ fn test_cp_with_options_backup_and_rem_when_dest_is_symlink() {
|
||||
fn test_cp_single_file() {
|
||||
let (_at, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.arg(TEST_HELLO_WORLD_SOURCE)
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_contains("missing destination file");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_cp_no_file() {
|
||||
let (_at, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.fails()
|
||||
.code_is(1)
|
||||
ucmd.fails_with_code(1)
|
||||
.stderr_contains("error: the following required arguments were not provided:");
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ fn generate(from: u32, to: u32) -> String {
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -1467,12 +1467,10 @@ fn test_directory_input_file() {
|
||||
|
||||
#[cfg(unix)]
|
||||
ucmd.args(&["test_directory", "1"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_only("csplit: read error: Is a directory\n");
|
||||
#[cfg(windows)]
|
||||
ucmd.args(&["test_directory", "1"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_only("csplit: cannot open 'test_directory' for reading: Permission denied\n");
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ fn test_no_args() {
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -107,24 +107,21 @@ fn test_whitespace_delimited() {
|
||||
fn test_whitespace_with_explicit_delimiter() {
|
||||
new_ucmd!()
|
||||
.args(&["-w", "-f", COMPLEX_SEQUENCE.sequence, "-d:"])
|
||||
.fails()
|
||||
.code_is(1);
|
||||
.fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_whitespace_with_byte() {
|
||||
new_ucmd!()
|
||||
.args(&["-w", "-b", COMPLEX_SEQUENCE.sequence])
|
||||
.fails()
|
||||
.code_is(1);
|
||||
.fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_whitespace_with_char() {
|
||||
new_ucmd!()
|
||||
.args(&["-c", COMPLEX_SEQUENCE.sequence, "-w"])
|
||||
.fails()
|
||||
.code_is(1);
|
||||
.fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -132,9 +129,9 @@ fn test_delimiter_with_byte_and_char() {
|
||||
for conflicting_arg in ["-c", "-b"] {
|
||||
new_ucmd!()
|
||||
.args(&[conflicting_arg, COMPLEX_SEQUENCE.sequence, "-d="])
|
||||
.fails()
|
||||
.fails_with_code(1)
|
||||
.stderr_is("cut: invalid input: The '--delimiter' ('-d') option only usable if printing a sequence of fields\n")
|
||||
.code_is(1);
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,8 +139,7 @@ fn test_delimiter_with_byte_and_char() {
|
||||
fn test_too_large() {
|
||||
new_ucmd!()
|
||||
.args(&["-b1-18446744073709551615", "/dev/null"])
|
||||
.fails()
|
||||
.code_is(1);
|
||||
.fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -240,8 +236,7 @@ fn test_is_a_directory() {
|
||||
|
||||
ucmd.arg("-b1")
|
||||
.arg("some")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_is("cut: some: Is a directory\n");
|
||||
}
|
||||
|
||||
@@ -250,8 +245,7 @@ fn test_no_such_file() {
|
||||
new_ucmd!()
|
||||
.arg("-b1")
|
||||
.arg("some")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_is("cut: some: No such file or directory\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ use uucore::process::geteuid;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -214,9 +214,8 @@ fn test_date_format_without_plus() {
|
||||
// [+FORMAT]
|
||||
new_ucmd!()
|
||||
.arg("%s")
|
||||
.fails()
|
||||
.stderr_contains("date: invalid date '%s'")
|
||||
.code_is(1);
|
||||
.fails_with_code(1)
|
||||
.stderr_contains("date: invalid date '%s'");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -99,7 +99,7 @@ fn build_ascii_block(n: usize) -> Vec<u8> {
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
// Sanity Tests
|
||||
@@ -1563,8 +1563,7 @@ fn test_nocache_stdin_error() {
|
||||
let detail = "Invalid seek";
|
||||
new_ucmd!()
|
||||
.args(&["iflag=nocache", "count=0", "status=noxfer"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_only(format!("dd: failed to discard cache for: 'standard input': {detail}\n0+0 records in\n0+0 records out\n"));
|
||||
}
|
||||
|
||||
@@ -1573,8 +1572,7 @@ fn test_nocache_stdin_error() {
|
||||
fn test_empty_count_number() {
|
||||
new_ucmd!()
|
||||
.args(&["count=B"])
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_only("dd: invalid number: ‘B’\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ use crate::common::util::TestScenario;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -9,7 +9,7 @@ use dircolors::{guess_syntax, OutputFmt, StrUtils};
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -6,7 +6,7 @@ use crate::common::util::TestScenario;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -77,7 +77,7 @@ fn du_basics(s: &str) {
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -132,20 +132,17 @@ fn test_du_invalid_size() {
|
||||
ts.ucmd()
|
||||
.arg(format!("--{s}=1fb4t"))
|
||||
.arg("/tmp")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_only(format!("du: invalid suffix in --{s} argument '1fb4t'\n"));
|
||||
ts.ucmd()
|
||||
.arg(format!("--{s}=x"))
|
||||
.arg("/tmp")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_only(format!("du: invalid --{s} argument 'x'\n"));
|
||||
ts.ucmd()
|
||||
.arg(format!("--{s}=1Y"))
|
||||
.arg("/tmp")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_only(format!("du: --{s} argument '1Y' too large\n"));
|
||||
}
|
||||
}
|
||||
@@ -1019,7 +1016,7 @@ fn test_du_symlink_fail() {
|
||||
|
||||
at.symlink_file("non-existing.txt", "target.txt");
|
||||
|
||||
ts.ucmd().arg("-L").arg("target.txt").fails().code_is(1);
|
||||
ts.ucmd().arg("-L").arg("target.txt").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
@@ -1086,8 +1083,7 @@ fn test_du_files0_from_with_invalid_zero_length_file_names() {
|
||||
|
||||
ts.ucmd()
|
||||
.arg("--files0-from=filelist")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stdout_contains("testfile")
|
||||
.stderr_contains("filelist:1: invalid zero-length file name")
|
||||
.stderr_contains("filelist:3: invalid zero-length file name");
|
||||
@@ -1133,8 +1129,7 @@ fn test_du_files0_from_stdin_with_invalid_zero_length_file_names() {
|
||||
new_ucmd!()
|
||||
.arg("--files0-from=-")
|
||||
.pipe_in("\0\0")
|
||||
.fails()
|
||||
.code_is(1)
|
||||
.fails_with_code(1)
|
||||
.stderr_contains("-:1: invalid zero-length file name")
|
||||
.stderr_contains("-:2: invalid zero-length file name");
|
||||
}
|
||||
|
||||
+30
-59
@@ -59,7 +59,7 @@ impl Drop for Target {
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(125);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(125);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -84,8 +84,7 @@ fn test_env_version() {
|
||||
fn test_env_permissions() {
|
||||
new_ucmd!()
|
||||
.arg(".")
|
||||
.fails()
|
||||
.code_is(126)
|
||||
.fails_with_code(126)
|
||||
.stderr_is("env: '.': Permission denied\n");
|
||||
}
|
||||
|
||||
@@ -537,106 +536,91 @@ fn test_env_parsing_errors() {
|
||||
|
||||
ts.ucmd()
|
||||
.arg("-S\\|echo hallo") // no quotes, invalid escape sequence |
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\|' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg("-S\\a") // no quotes, invalid escape sequence a
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\a' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg("-S\"\\a\"") // double quotes, invalid escape sequence a
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\a' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r#"-S"\a""#) // same as before, just using r#""#
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\a' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg("-S'\\a'") // single quotes, invalid escape sequence a
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\a' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r"-S\|\&\;") // no quotes, invalid escape sequence |
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\|' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r"-S\<\&\;") // no quotes, invalid escape sequence <
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\<' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r"-S\>\&\;") // no quotes, invalid escape sequence >
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\>' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r"-S\`\&\;") // no quotes, invalid escape sequence `
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\`' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r#"-S"\`\&\;""#) // double quotes, invalid escape sequence `
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\`' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r"-S'\`\&\;'") // single quotes, invalid escape sequence `
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\`' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r"-S\`") // ` escaped without quotes
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\`' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r#"-S"\`""#) // ` escaped in double quotes
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\`' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.arg(r"-S'\`'") // ` escaped in single quotes
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\`' in -S\n");
|
||||
|
||||
ts.ucmd()
|
||||
.args(&[r"-S\🦉"]) // ` escaped in single quotes
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.no_stdout()
|
||||
.stderr_is("env: invalid sequence '\\\u{FFFD}' in -S\n"); // gnu doesn't show the owl. Instead a invalid unicode ?
|
||||
}
|
||||
@@ -647,8 +631,7 @@ fn test_env_with_empty_executable_single_quotes() {
|
||||
|
||||
ts.ucmd()
|
||||
.args(&["-S''"]) // empty single quotes, considered as program name
|
||||
.fails()
|
||||
.code_is(127)
|
||||
.fails_with_code(127)
|
||||
.no_stdout()
|
||||
.stderr_is("env: '': No such file or directory\n"); // gnu version again adds escaping here
|
||||
}
|
||||
@@ -659,8 +642,7 @@ fn test_env_with_empty_executable_double_quotes() {
|
||||
|
||||
ts.ucmd()
|
||||
.args(&["-S\"\""]) // empty double quotes, considered as program name
|
||||
.fails()
|
||||
.code_is(127)
|
||||
.fails_with_code(127)
|
||||
.no_stdout()
|
||||
.stderr_is("env: '': No such file or directory\n");
|
||||
}
|
||||
@@ -801,23 +783,19 @@ fn test_env_arg_ignore_signal_invalid_signals() {
|
||||
let ts = TestScenario::new(util_name!());
|
||||
ts.ucmd()
|
||||
.args(&["--ignore-signal=banana"])
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.stderr_contains("env: 'banana': invalid signal");
|
||||
ts.ucmd()
|
||||
.args(&["--ignore-signal=SIGbanana"])
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.stderr_contains("env: 'SIGbanana': invalid signal");
|
||||
ts.ucmd()
|
||||
.args(&["--ignore-signal=exit"])
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.stderr_contains("env: 'exit': invalid signal");
|
||||
ts.ucmd()
|
||||
.args(&["--ignore-signal=SIGexit"])
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.stderr_contains("env: 'SIGexit': invalid signal");
|
||||
}
|
||||
|
||||
@@ -829,32 +807,28 @@ fn test_env_arg_ignore_signal_special_signals() {
|
||||
let signal_kill = nix::sys::signal::SIGKILL;
|
||||
ts.ucmd()
|
||||
.args(&["--ignore-signal=stop", "echo", "hello"])
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.stderr_contains(format!(
|
||||
"env: failed to set signal action for signal {}: Invalid argument",
|
||||
signal_stop as i32
|
||||
));
|
||||
ts.ucmd()
|
||||
.args(&["--ignore-signal=kill", "echo", "hello"])
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.stderr_contains(format!(
|
||||
"env: failed to set signal action for signal {}: Invalid argument",
|
||||
signal_kill as i32
|
||||
));
|
||||
ts.ucmd()
|
||||
.args(&["--ignore-signal=SToP", "echo", "hello"])
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.stderr_contains(format!(
|
||||
"env: failed to set signal action for signal {}: Invalid argument",
|
||||
signal_stop as i32
|
||||
));
|
||||
ts.ucmd()
|
||||
.args(&["--ignore-signal=SIGKILL", "echo", "hello"])
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.stderr_contains(format!(
|
||||
"env: failed to set signal action for signal {}: Invalid argument",
|
||||
signal_kill as i32
|
||||
@@ -898,19 +872,16 @@ fn disallow_equals_sign_on_short_unset_option() {
|
||||
|
||||
ts.ucmd()
|
||||
.arg("-u=")
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.stderr_contains("env: cannot unset '=': Invalid argument");
|
||||
ts.ucmd()
|
||||
.arg("-u=A1B2C3")
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.stderr_contains("env: cannot unset '=A1B2C3': Invalid argument");
|
||||
ts.ucmd().arg("--split-string=A1B=2C3=").succeeds();
|
||||
ts.ucmd()
|
||||
.arg("--unset=")
|
||||
.fails()
|
||||
.code_is(125)
|
||||
.fails_with_code(125)
|
||||
.stderr_contains("env: cannot unset '': Invalid argument");
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use uucore::display::Quotable;
|
||||
|
||||
#[test]
|
||||
fn test_invalid_arg() {
|
||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||
new_ucmd!().arg("--definitely-invalid").fails_with_code(1);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user