mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
Merge pull request #4261 from Joining7943/tests-util-enhance-cmdresult
`tests/util`: Implement enhancements of `CmdResult` #4259
This commit is contained in:
commit
fc7e51a4f8
42 changed files with 782 additions and 435 deletions
|
@ -400,7 +400,7 @@ sha1 = { version="0.10", features=["std"] }
|
||||||
tempfile = "3"
|
tempfile = "3"
|
||||||
time = {version="0.3", features=["local-offset"]}
|
time = {version="0.3", features=["local-offset"]}
|
||||||
unindent = "0.1"
|
unindent = "0.1"
|
||||||
uucore = { version=">=0.0.17", package="uucore", path="src/uucore", features=["entries", "process"] }
|
uucore = { version=">=0.0.17", package="uucore", path="src/uucore", features=["entries", "process", "signals"] }
|
||||||
walkdir = "2.2"
|
walkdir = "2.2"
|
||||||
atty = "0.2"
|
atty = "0.2"
|
||||||
hex-literal = "0.3.1"
|
hex-literal = "0.3.1"
|
||||||
|
|
|
@ -121,5 +121,5 @@ fn test_base32_file_not_found() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("a.txt")
|
.arg("a.txt")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("base32: a.txt: No such file or directory");
|
.stderr_only("base32: a.txt: No such file or directory\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,5 +110,5 @@ fn test_base64_file_not_found() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("a.txt")
|
.arg("a.txt")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("base64: a.txt: No such file or directory");
|
.stderr_only("base64: a.txt: No such file or directory\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,10 @@ fn test_z85_not_padded() {
|
||||||
.args(&["--z85", "-d"])
|
.args(&["--z85", "-d"])
|
||||||
.pipe_in("##########")
|
.pipe_in("##########")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("basenc: error: invalid input");
|
.stderr_only("basenc: error: invalid input\n");
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--z85"])
|
.args(&["--z85"])
|
||||||
.pipe_in("123")
|
.pipe_in("123")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("basenc: error: invalid input (length must be multiple of 4 characters)");
|
.stderr_only("basenc: error: invalid input (length must be multiple of 4 characters)\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,7 @@ fn test_directory() {
|
||||||
s.ucmd()
|
s.ucmd()
|
||||||
.args(&["test_directory"])
|
.args(&["test_directory"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("cat: test_directory: Is a directory");
|
.stderr_is("cat: test_directory: Is a directory\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -194,7 +194,7 @@ fn test_directory_and_file() {
|
||||||
s.ucmd()
|
s.ucmd()
|
||||||
.args(&["test_directory2", fixture])
|
.args(&["test_directory2", fixture])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("cat: test_directory2: Is a directory")
|
.stderr_is("cat: test_directory2: Is a directory\n")
|
||||||
.stdout_is_fixture(fixture);
|
.stdout_is_fixture(fixture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ fn test_write_to_self() {
|
||||||
.arg("second_file")
|
.arg("second_file")
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(2)
|
.code_is(2)
|
||||||
.stderr_only("cat: first_file: input file is output file\ncat: first_file: input file is output file");
|
.stderr_only("cat: first_file: input file is output file\ncat: first_file: input file is output file\n");
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
s.fixtures.read("first_file"),
|
s.fixtures.read("first_file"),
|
||||||
|
|
|
@ -48,7 +48,7 @@ fn test_invalid_group() {
|
||||||
.arg("__nosuchgroup__")
|
.arg("__nosuchgroup__")
|
||||||
.arg("/")
|
.arg("/")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("chgrp: invalid group: '__nosuchgroup__'");
|
.stderr_is("chgrp: invalid group: '__nosuchgroup__'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -92,7 +92,7 @@ fn test_preserve_root() {
|
||||||
.arg("-R")
|
.arg("-R")
|
||||||
.arg("bin").arg(d)
|
.arg("bin").arg(d)
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("chgrp: it is dangerous to operate recursively on '/'\nchgrp: use --no-preserve-root to override this failsafe");
|
.stderr_is("chgrp: it is dangerous to operate recursively on '/'\nchgrp: use --no-preserve-root to override this failsafe\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ fn test_preserve_root_symlink() {
|
||||||
.arg("-HR")
|
.arg("-HR")
|
||||||
.arg("bin").arg(file)
|
.arg("bin").arg(file)
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("chgrp: it is dangerous to operate recursively on '/'\nchgrp: use --no-preserve-root to override this failsafe");
|
.stderr_is("chgrp: it is dangerous to operate recursively on '/'\nchgrp: use --no-preserve-root to override this failsafe\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
@ -120,7 +120,7 @@ fn test_preserve_root_symlink() {
|
||||||
.arg("-HR")
|
.arg("-HR")
|
||||||
.arg("bin").arg(format!(".//{}/..//..//../../", file))
|
.arg("bin").arg(format!(".//{}/..//..//../../", file))
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("chgrp: it is dangerous to operate recursively on '/'\nchgrp: use --no-preserve-root to override this failsafe");
|
.stderr_is("chgrp: it is dangerous to operate recursively on '/'\nchgrp: use --no-preserve-root to override this failsafe\n");
|
||||||
|
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
at.symlink_file("/", "__root__");
|
at.symlink_file("/", "__root__");
|
||||||
|
@ -128,7 +128,7 @@ fn test_preserve_root_symlink() {
|
||||||
.arg("-R")
|
.arg("-R")
|
||||||
.arg("bin").arg("__root__/.")
|
.arg("bin").arg("__root__/.")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("chgrp: it is dangerous to operate recursively on '/'\nchgrp: use --no-preserve-root to override this failsafe");
|
.stderr_is("chgrp: it is dangerous to operate recursively on '/'\nchgrp: use --no-preserve-root to override this failsafe\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -143,7 +143,7 @@ fn test_reference() {
|
||||||
.arg("--reference=/etc/passwd")
|
.arg("--reference=/etc/passwd")
|
||||||
.arg("/etc")
|
.arg("/etc")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("chgrp: changing group of '/etc': Operation not permitted (os error 1)\nfailed to change group of '/etc' from root to root");
|
.stderr_is("chgrp: changing group of '/etc': Operation not permitted (os error 1)\nfailed to change group of '/etc' from root to root\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -270,7 +270,7 @@ fn test_permission_denied() {
|
||||||
.arg(group.as_raw().to_string())
|
.arg(group.as_raw().to_string())
|
||||||
.arg("dir")
|
.arg("dir")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("chgrp: cannot access 'dir': Permission denied");
|
.stderr_only("chgrp: cannot access 'dir': Permission denied\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@ fn test_subdir_permission_denied() {
|
||||||
.arg(group.as_raw().to_string())
|
.arg(group.as_raw().to_string())
|
||||||
.arg("dir")
|
.arg("dir")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("chgrp: cannot access 'dir/subdir': Permission denied");
|
.stderr_only("chgrp: cannot access 'dir/subdir': Permission denied\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ fn test_chmod_ugoa() {
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
// spell-checker:disable-next-line
|
// spell-checker:disable-next-line
|
||||||
.stderr_is("chmod: file: new permissions are r-xrwxrwx, not r-xr-xr-x");
|
.stderr_is("chmod: file: new permissions are r-xrwxrwx, not r-xr-xr-x\n");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
metadata(at.plus("file")).unwrap().permissions().mode(),
|
metadata(at.plus("file")).unwrap().permissions().mode(),
|
||||||
0o100577
|
0o100577
|
||||||
|
@ -314,7 +314,7 @@ fn test_permission_denied() {
|
||||||
.arg("o=r")
|
.arg("o=r")
|
||||||
.arg("d")
|
.arg("d")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("chmod: 'd/no-x/y': Permission denied");
|
.stderr_is("chmod: 'd/no-x/y': Permission denied\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -341,7 +341,7 @@ fn test_chmod_recursive() {
|
||||||
.arg("a")
|
.arg("a")
|
||||||
.arg("z")
|
.arg("z")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("chmod: Permission denied");
|
.stderr_is("chmod: Permission denied\n");
|
||||||
|
|
||||||
assert_eq!(at.metadata("z/y").permissions().mode(), 0o100444);
|
assert_eq!(at.metadata("z/y").permissions().mode(), 0o100444);
|
||||||
assert_eq!(at.metadata("a/a").permissions().mode(), 0o100444);
|
assert_eq!(at.metadata("a/a").permissions().mode(), 0o100444);
|
||||||
|
|
|
@ -43,7 +43,7 @@ fn test_no_such_directory() {
|
||||||
|
|
||||||
ucmd.arg("a")
|
ucmd.arg("a")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("chroot: cannot change root directory to 'a': no such directory")
|
.stderr_is("chroot: cannot change root directory to 'a': no such directory\n")
|
||||||
.code_is(125);
|
.code_is(125);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -179,5 +179,5 @@ fn test_no_such_file() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["bogus_file_1", "bogus_file_2"])
|
.args(&["bogus_file_1", "bogus_file_2"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("comm: bogus_file_1: No such file or directory");
|
.stderr_only("comm: bogus_file_1: No such file or directory\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -601,7 +601,7 @@ fn test_cp_backup_simple_protect_source() {
|
||||||
.arg(TEST_HELLO_WORLD_SOURCE)
|
.arg(TEST_HELLO_WORLD_SOURCE)
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only(format!(
|
.stderr_only(format!(
|
||||||
"cp: backing up '{}' might destroy source; '{}' not copied",
|
"cp: backing up '{}' might destroy source; '{}' not copied\n",
|
||||||
TEST_HELLO_WORLD_SOURCE, source,
|
TEST_HELLO_WORLD_SOURCE, source,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -1524,7 +1524,7 @@ fn test_cp_reflink_insufficient_permission() {
|
||||||
.arg("unreadable")
|
.arg("unreadable")
|
||||||
.arg(TEST_EXISTING_FILE)
|
.arg(TEST_EXISTING_FILE)
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("cp: 'unreadable' -> 'existing_file.txt': Permission denied (os error 13)");
|
.stderr_only("cp: 'unreadable' -> 'existing_file.txt': Permission denied (os error 13)\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
|
@ -1863,9 +1863,9 @@ fn test_copy_through_just_created_symlink() {
|
||||||
.arg("c")
|
.arg("c")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only(if cfg!(not(target_os = "windows")) {
|
.stderr_only(if cfg!(not(target_os = "windows")) {
|
||||||
"cp: will not copy 'b/1' through just-created symlink 'c/1'"
|
"cp: will not copy 'b/1' through just-created symlink 'c/1'\n"
|
||||||
} else {
|
} else {
|
||||||
"cp: will not copy 'b/1' through just-created symlink 'c\\1'"
|
"cp: will not copy 'b/1' through just-created symlink 'c\\1'\n"
|
||||||
});
|
});
|
||||||
if create_t {
|
if create_t {
|
||||||
assert_eq!(at.read("a/1"), "world");
|
assert_eq!(at.read("a/1"), "world");
|
||||||
|
@ -1881,7 +1881,7 @@ fn test_copy_through_dangling_symlink() {
|
||||||
ucmd.arg("file")
|
ucmd.arg("file")
|
||||||
.arg("target")
|
.arg("target")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("cp: not writing through dangling symlink 'target'");
|
.stderr_only("cp: not writing through dangling symlink 'target'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1933,7 +1933,7 @@ fn test_copy_through_dangling_symlink_no_dereference_2() {
|
||||||
at.symlink_file("nonexistent", "target");
|
at.symlink_file("nonexistent", "target");
|
||||||
ucmd.args(&["-P", "file", "target"])
|
ucmd.args(&["-P", "file", "target"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("cp: not writing through dangling symlink 'target'");
|
.stderr_only("cp: not writing through dangling symlink 'target'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Test that copy through a dangling symbolic link fails, even with --force.
|
/// Test that copy through a dangling symbolic link fails, even with --force.
|
||||||
|
@ -1945,7 +1945,7 @@ fn test_copy_through_dangling_symlink_force() {
|
||||||
at.symlink_file("no-such-file", "dest");
|
at.symlink_file("no-such-file", "dest");
|
||||||
ucmd.args(&["--force", "src", "dest"])
|
ucmd.args(&["--force", "src", "dest"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("cp: not writing through dangling symlink 'dest'");
|
.stderr_only("cp: not writing through dangling symlink 'dest'\n");
|
||||||
assert!(!at.file_exists("dest"));
|
assert!(!at.file_exists("dest"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1958,7 +1958,7 @@ fn test_cp_archive_on_nonexistent_file() {
|
||||||
.arg(TEST_EXISTING_FILE)
|
.arg(TEST_EXISTING_FILE)
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only(
|
.stderr_only(
|
||||||
"cp: cannot stat 'nonexistent_file.txt': No such file or directory (os error 2)",
|
"cp: cannot stat 'nonexistent_file.txt': No such file or directory (os error 2)\n",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2043,7 +2043,7 @@ fn test_cp_dir_vs_file() {
|
||||||
.arg(TEST_COPY_FROM_FOLDER)
|
.arg(TEST_COPY_FROM_FOLDER)
|
||||||
.arg(TEST_EXISTING_FILE)
|
.arg(TEST_EXISTING_FILE)
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("cp: cannot overwrite non-directory with directory");
|
.stderr_only("cp: cannot overwrite non-directory with directory\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -2285,9 +2285,9 @@ fn test_copy_directory_to_itself_disallowed() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
at.mkdir("d");
|
at.mkdir("d");
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
let expected = "cp: cannot copy a directory, 'd', into itself, 'd/d'";
|
let expected = "cp: cannot copy a directory, 'd', into itself, 'd/d'\n";
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let expected = "cp: cannot copy a directory, 'd', into itself, 'd\\d'";
|
let expected = "cp: cannot copy a directory, 'd', into itself, 'd\\d'\n";
|
||||||
ucmd.args(&["-R", "d", "d"]).fails().stderr_only(expected);
|
ucmd.args(&["-R", "d", "d"]).fails().stderr_only(expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2299,9 +2299,9 @@ fn test_copy_nested_directory_to_itself_disallowed() {
|
||||||
at.mkdir("a/b");
|
at.mkdir("a/b");
|
||||||
at.mkdir("a/b/c");
|
at.mkdir("a/b/c");
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
let expected = "cp: cannot copy a directory, 'a/b', into itself, 'a/b/c/b'";
|
let expected = "cp: cannot copy a directory, 'a/b', into itself, 'a/b/c/b'\n";
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let expected = "cp: cannot copy a directory, 'a/b', into itself, 'a/b/c\\b'";
|
let expected = "cp: cannot copy a directory, 'a/b', into itself, 'a/b/c\\b'\n";
|
||||||
ucmd.args(&["-R", "a/b", "a/b/c"])
|
ucmd.args(&["-R", "a/b", "a/b/c"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only(expected);
|
.stderr_only(expected);
|
||||||
|
@ -2361,7 +2361,7 @@ fn test_copy_dir_preserve_permissions_inaccessible_file() {
|
||||||
ucmd.args(&["-p", "-R", "d1", "d2"])
|
ucmd.args(&["-p", "-R", "d1", "d2"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("cp: cannot open 'd1/f' for reading: Permission denied");
|
.stderr_only("cp: cannot open 'd1/f' for reading: Permission denied\n");
|
||||||
assert!(at.dir_exists("d2"));
|
assert!(at.dir_exists("d2"));
|
||||||
assert!(!at.file_exists("d2/f"));
|
assert!(!at.file_exists("d2/f"));
|
||||||
|
|
||||||
|
@ -2378,7 +2378,7 @@ fn test_same_file_backup() {
|
||||||
at.touch("f");
|
at.touch("f");
|
||||||
ucmd.args(&["--backup", "f", "f"])
|
ucmd.args(&["--backup", "f", "f"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("cp: 'f' and 'f' are the same file");
|
.stderr_only("cp: 'f' and 'f' are the same file\n");
|
||||||
assert!(!at.file_exists("f~"));
|
assert!(!at.file_exists("f~"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2390,7 +2390,7 @@ fn test_same_file_force() {
|
||||||
at.touch("f");
|
at.touch("f");
|
||||||
ucmd.args(&["--force", "f", "f"])
|
ucmd.args(&["--force", "f", "f"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("cp: 'f' and 'f' are the same file");
|
.stderr_only("cp: 'f' and 'f' are the same file\n");
|
||||||
assert!(!at.file_exists("f~"));
|
assert!(!at.file_exists("f~"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -213,7 +213,7 @@ fn test_up_to_match_repeat_over() {
|
||||||
ucmd.args(&["numbers50.txt", "/9$/", "{50}"])
|
ucmd.args(&["numbers50.txt", "/9$/", "{50}"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("16\n29\n30\n30\n30\n6\n")
|
.stdout_is("16\n29\n30\n30\n30\n6\n")
|
||||||
.stderr_is("csplit: '/9$/': match not found on repetition 5");
|
.stderr_is("csplit: '/9$/': match not found on repetition 5\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("there should be splits created")
|
.expect("there should be splits created")
|
||||||
|
@ -224,7 +224,7 @@ fn test_up_to_match_repeat_over() {
|
||||||
ucmd.args(&["numbers50.txt", "/9$/", "{50}", "-k"])
|
ucmd.args(&["numbers50.txt", "/9$/", "{50}", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("16\n29\n30\n30\n30\n6\n")
|
.stdout_is("16\n29\n30\n30\n30\n6\n")
|
||||||
.stderr_is("csplit: '/9$/': match not found on repetition 5");
|
.stderr_is("csplit: '/9$/': match not found on repetition 5\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("there should be splits created")
|
.expect("there should be splits created")
|
||||||
|
@ -370,7 +370,7 @@ fn test_option_keep() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["-k", "numbers50.txt", "/20/", "/nope/"])
|
ucmd.args(&["-k", "numbers50.txt", "/20/", "/nope/"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("csplit: '/nope/': match not found")
|
.stderr_is("csplit: '/nope/': match not found\n")
|
||||||
.stdout_is("48\n93\n");
|
.stdout_is("48\n93\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
|
@ -546,7 +546,7 @@ fn test_up_to_match_context_overflow() {
|
||||||
ucmd.args(&["numbers50.txt", "/45/+10"])
|
ucmd.args(&["numbers50.txt", "/45/+10"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("141\n")
|
.stdout_is("141\n")
|
||||||
.stderr_is("csplit: '/45/+10': line number out of range");
|
.stderr_is("csplit: '/45/+10': line number out of range\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -557,7 +557,7 @@ fn test_up_to_match_context_overflow() {
|
||||||
ucmd.args(&["numbers50.txt", "/45/+10", "-k"])
|
ucmd.args(&["numbers50.txt", "/45/+10", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("141\n")
|
.stdout_is("141\n")
|
||||||
.stderr_is("csplit: '/45/+10': line number out of range");
|
.stderr_is("csplit: '/45/+10': line number out of range\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -572,7 +572,7 @@ fn test_skip_to_match_context_underflow() {
|
||||||
ucmd.args(&["numbers50.txt", "%5%-10"])
|
ucmd.args(&["numbers50.txt", "%5%-10"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("141\n")
|
.stdout_is("141\n")
|
||||||
.stderr_is("csplit: '%5%-10': line number out of range");
|
.stderr_is("csplit: '%5%-10': line number out of range\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -583,7 +583,7 @@ fn test_skip_to_match_context_underflow() {
|
||||||
ucmd.args(&["numbers50.txt", "%5%-10", "-k"])
|
ucmd.args(&["numbers50.txt", "%5%-10", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("141\n")
|
.stdout_is("141\n")
|
||||||
.stderr_is("csplit: '%5%-10': line number out of range");
|
.stderr_is("csplit: '%5%-10': line number out of range\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -597,7 +597,7 @@ fn test_skip_to_match_context_overflow() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "%45%+10"])
|
ucmd.args(&["numbers50.txt", "%45%+10"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("csplit: '%45%+10': line number out of range");
|
.stderr_is("csplit: '%45%+10': line number out of range\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -607,7 +607,7 @@ fn test_skip_to_match_context_overflow() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "%45%+10", "-k"])
|
ucmd.args(&["numbers50.txt", "%45%+10", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("csplit: '%45%+10': line number out of range");
|
.stderr_only("csplit: '%45%+10': line number out of range\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -621,7 +621,7 @@ fn test_up_to_no_match1() {
|
||||||
ucmd.args(&["numbers50.txt", "/4/", "/nope/"])
|
ucmd.args(&["numbers50.txt", "/4/", "/nope/"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("6\n135\n")
|
.stdout_is("6\n135\n")
|
||||||
.stderr_is("csplit: '/nope/': match not found");
|
.stderr_is("csplit: '/nope/': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -632,7 +632,7 @@ fn test_up_to_no_match1() {
|
||||||
ucmd.args(&["numbers50.txt", "/4/", "/nope/", "-k"])
|
ucmd.args(&["numbers50.txt", "/4/", "/nope/", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("6\n135\n")
|
.stdout_is("6\n135\n")
|
||||||
.stderr_is("csplit: '/nope/': match not found");
|
.stderr_is("csplit: '/nope/': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -648,7 +648,7 @@ fn test_up_to_no_match2() {
|
||||||
ucmd.args(&["numbers50.txt", "/4/", "/nope/", "{50}"])
|
ucmd.args(&["numbers50.txt", "/4/", "/nope/", "{50}"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("6\n135\n")
|
.stdout_is("6\n135\n")
|
||||||
.stderr_is("csplit: '/nope/': match not found");
|
.stderr_is("csplit: '/nope/': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -659,7 +659,7 @@ fn test_up_to_no_match2() {
|
||||||
ucmd.args(&["numbers50.txt", "/4/", "/nope/", "{50}", "-k"])
|
ucmd.args(&["numbers50.txt", "/4/", "/nope/", "{50}", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("6\n135\n")
|
.stdout_is("6\n135\n")
|
||||||
.stderr_is("csplit: '/nope/': match not found");
|
.stderr_is("csplit: '/nope/': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -675,7 +675,7 @@ fn test_up_to_no_match3() {
|
||||||
ucmd.args(&["numbers50.txt", "/0$/", "{50}"])
|
ucmd.args(&["numbers50.txt", "/0$/", "{50}"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("18\n30\n30\n30\n30\n3\n")
|
.stdout_is("18\n30\n30\n30\n30\n3\n")
|
||||||
.stderr_is("csplit: '/0$/': match not found on repetition 5");
|
.stderr_is("csplit: '/0$/': match not found on repetition 5\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -686,7 +686,7 @@ fn test_up_to_no_match3() {
|
||||||
ucmd.args(&["numbers50.txt", "/0$/", "{50}", "-k"])
|
ucmd.args(&["numbers50.txt", "/0$/", "{50}", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("18\n30\n30\n30\n30\n3\n")
|
.stdout_is("18\n30\n30\n30\n30\n3\n")
|
||||||
.stderr_is("csplit: '/0$/': match not found on repetition 5");
|
.stderr_is("csplit: '/0$/': match not found on repetition 5\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -706,7 +706,7 @@ fn test_up_to_no_match4() {
|
||||||
ucmd.args(&["numbers50.txt", "/nope/", "/4/"])
|
ucmd.args(&["numbers50.txt", "/nope/", "/4/"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("141\n")
|
.stdout_is("141\n")
|
||||||
.stderr_is("csplit: '/nope/': match not found");
|
.stderr_is("csplit: '/nope/': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -717,7 +717,7 @@ fn test_up_to_no_match4() {
|
||||||
ucmd.args(&["numbers50.txt", "/nope/", "/4/", "-k"])
|
ucmd.args(&["numbers50.txt", "/nope/", "/4/", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("141\n")
|
.stdout_is("141\n")
|
||||||
.stderr_is("csplit: '/nope/': match not found");
|
.stderr_is("csplit: '/nope/': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -746,7 +746,7 @@ fn test_up_to_no_match6() {
|
||||||
ucmd.args(&["numbers50.txt", "/nope/-5"])
|
ucmd.args(&["numbers50.txt", "/nope/-5"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("141\n")
|
.stdout_is("141\n")
|
||||||
.stderr_is("csplit: '/nope/-5': match not found");
|
.stderr_is("csplit: '/nope/-5': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -757,7 +757,7 @@ fn test_up_to_no_match6() {
|
||||||
ucmd.args(&["numbers50.txt", "/nope/-5", "-k"])
|
ucmd.args(&["numbers50.txt", "/nope/-5", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("141\n")
|
.stdout_is("141\n")
|
||||||
.stderr_is("csplit: '/nope/-5': match not found");
|
.stderr_is("csplit: '/nope/-5': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -772,7 +772,7 @@ fn test_up_to_no_match7() {
|
||||||
ucmd.args(&["numbers50.txt", "/nope/+5"])
|
ucmd.args(&["numbers50.txt", "/nope/+5"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("141\n")
|
.stdout_is("141\n")
|
||||||
.stderr_is("csplit: '/nope/+5': match not found");
|
.stderr_is("csplit: '/nope/+5': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -783,7 +783,7 @@ fn test_up_to_no_match7() {
|
||||||
ucmd.args(&["numbers50.txt", "/nope/+5", "-k"])
|
ucmd.args(&["numbers50.txt", "/nope/+5", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("141\n")
|
.stdout_is("141\n")
|
||||||
.stderr_is("csplit: '/nope/+5': match not found");
|
.stderr_is("csplit: '/nope/+5': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -797,7 +797,7 @@ fn test_skip_to_no_match1() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "%nope%"])
|
ucmd.args(&["numbers50.txt", "%nope%"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("csplit: '%nope%': match not found");
|
.stderr_only("csplit: '%nope%': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -810,7 +810,7 @@ fn test_skip_to_no_match2() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "%nope%", "{50}"])
|
ucmd.args(&["numbers50.txt", "%nope%", "{50}"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("csplit: '%nope%': match not found");
|
.stderr_only("csplit: '%nope%': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -823,7 +823,7 @@ fn test_skip_to_no_match3() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "%0$%", "{50}"])
|
ucmd.args(&["numbers50.txt", "%0$%", "{50}"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("csplit: '%0$%': match not found on repetition 5");
|
.stderr_only("csplit: '%0$%': match not found on repetition 5\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -836,7 +836,7 @@ fn test_skip_to_no_match4() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "%nope%", "/4/"])
|
ucmd.args(&["numbers50.txt", "%nope%", "/4/"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("csplit: '%nope%': match not found");
|
.stderr_only("csplit: '%nope%': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -863,7 +863,7 @@ fn test_skip_to_no_match6() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "%nope%-5"])
|
ucmd.args(&["numbers50.txt", "%nope%-5"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("csplit: '%nope%-5': match not found");
|
.stderr_only("csplit: '%nope%-5': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -876,7 +876,7 @@ fn test_skip_to_no_match7() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "%nope%+5"])
|
ucmd.args(&["numbers50.txt", "%nope%+5"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("csplit: '%nope%+5': match not found");
|
.stderr_only("csplit: '%nope%+5': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -889,7 +889,7 @@ fn test_no_match() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "%nope%"])
|
ucmd.args(&["numbers50.txt", "%nope%"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("csplit: '%nope%': match not found");
|
.stderr_only("csplit: '%nope%': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -900,7 +900,7 @@ fn test_no_match() {
|
||||||
ucmd.args(&["numbers50.txt", "/nope/"])
|
ucmd.args(&["numbers50.txt", "/nope/"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("141\n")
|
.stdout_is("141\n")
|
||||||
.stderr_is("csplit: '/nope/': match not found");
|
.stderr_is("csplit: '/nope/': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -997,7 +997,7 @@ fn test_too_small_line_num_repeat() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "/20/", "10", "{*}"])
|
ucmd.args(&["numbers50.txt", "/20/", "10", "{*}"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("csplit: '10': line number out of range on repetition 5")
|
.stderr_is("csplit: '10': line number out of range on repetition 5\n")
|
||||||
.stdout_is("48\n0\n0\n30\n30\n30\n3\n");
|
.stdout_is("48\n0\n0\n30\n30\n30\n3\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
|
@ -1008,7 +1008,7 @@ fn test_too_small_line_num_repeat() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "/20/", "10", "{*}", "-k"])
|
ucmd.args(&["numbers50.txt", "/20/", "10", "{*}", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("csplit: '10': line number out of range on repetition 5")
|
.stderr_is("csplit: '10': line number out of range on repetition 5\n")
|
||||||
.stdout_is("48\n0\n0\n30\n30\n30\n3\n");
|
.stdout_is("48\n0\n0\n30\n30\n30\n3\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
|
@ -1030,7 +1030,7 @@ fn test_line_num_out_of_range1() {
|
||||||
ucmd.args(&["numbers50.txt", "100"])
|
ucmd.args(&["numbers50.txt", "100"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("141\n")
|
.stdout_is("141\n")
|
||||||
.stderr_is("csplit: '100': line number out of range");
|
.stderr_is("csplit: '100': line number out of range\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("there should be splits created")
|
.expect("there should be splits created")
|
||||||
|
@ -1041,7 +1041,7 @@ fn test_line_num_out_of_range1() {
|
||||||
ucmd.args(&["numbers50.txt", "100", "-k"])
|
ucmd.args(&["numbers50.txt", "100", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("141\n")
|
.stdout_is("141\n")
|
||||||
.stderr_is("csplit: '100': line number out of range");
|
.stderr_is("csplit: '100': line number out of range\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("there should be splits created")
|
.expect("there should be splits created")
|
||||||
|
@ -1056,7 +1056,7 @@ fn test_line_num_out_of_range2() {
|
||||||
ucmd.args(&["numbers50.txt", "10", "100"])
|
ucmd.args(&["numbers50.txt", "10", "100"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("18\n123\n")
|
.stdout_is("18\n123\n")
|
||||||
.stderr_is("csplit: '100': line number out of range");
|
.stderr_is("csplit: '100': line number out of range\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("there should be splits created")
|
.expect("there should be splits created")
|
||||||
|
@ -1067,7 +1067,7 @@ fn test_line_num_out_of_range2() {
|
||||||
ucmd.args(&["numbers50.txt", "10", "100", "-k"])
|
ucmd.args(&["numbers50.txt", "10", "100", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("18\n123\n")
|
.stdout_is("18\n123\n")
|
||||||
.stderr_is("csplit: '100': line number out of range");
|
.stderr_is("csplit: '100': line number out of range\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("there should be splits created")
|
.expect("there should be splits created")
|
||||||
|
@ -1083,7 +1083,7 @@ fn test_line_num_out_of_range3() {
|
||||||
ucmd.args(&["numbers50.txt", "40", "{2}"])
|
ucmd.args(&["numbers50.txt", "40", "{2}"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("108\n33\n")
|
.stdout_is("108\n33\n")
|
||||||
.stderr_is("csplit: '40': line number out of range on repetition 1");
|
.stderr_is("csplit: '40': line number out of range on repetition 1\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("there should be splits created")
|
.expect("there should be splits created")
|
||||||
|
@ -1094,7 +1094,7 @@ fn test_line_num_out_of_range3() {
|
||||||
ucmd.args(&["numbers50.txt", "40", "{2}", "-k"])
|
ucmd.args(&["numbers50.txt", "40", "{2}", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("108\n33\n")
|
.stdout_is("108\n33\n")
|
||||||
.stderr_is("csplit: '40': line number out of range on repetition 1");
|
.stderr_is("csplit: '40': line number out of range on repetition 1\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("there should be splits created")
|
.expect("there should be splits created")
|
||||||
|
@ -1110,7 +1110,7 @@ fn test_line_num_out_of_range4() {
|
||||||
ucmd.args(&["numbers50.txt", "40", "{*}"])
|
ucmd.args(&["numbers50.txt", "40", "{*}"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("108\n33\n")
|
.stdout_is("108\n33\n")
|
||||||
.stderr_is("csplit: '40': line number out of range on repetition 1");
|
.stderr_is("csplit: '40': line number out of range on repetition 1\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("there should be splits created")
|
.expect("there should be splits created")
|
||||||
|
@ -1121,7 +1121,7 @@ fn test_line_num_out_of_range4() {
|
||||||
ucmd.args(&["numbers50.txt", "40", "{*}", "-k"])
|
ucmd.args(&["numbers50.txt", "40", "{*}", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("108\n33\n")
|
.stdout_is("108\n33\n")
|
||||||
.stderr_is("csplit: '40': line number out of range on repetition 1");
|
.stderr_is("csplit: '40': line number out of range on repetition 1\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("there should be splits created")
|
.expect("there should be splits created")
|
||||||
|
@ -1137,7 +1137,7 @@ fn test_skip_to_match_negative_offset_before_a_match() {
|
||||||
ucmd.args(&["numbers50.txt", "/20/-10", "/15/"])
|
ucmd.args(&["numbers50.txt", "/20/-10", "/15/"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("18\n123\n")
|
.stdout_is("18\n123\n")
|
||||||
.stderr_is("csplit: '/15/': match not found");
|
.stderr_is("csplit: '/15/': match not found\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("there should be splits created")
|
.expect("there should be splits created")
|
||||||
|
@ -1182,7 +1182,7 @@ fn test_corner_case2() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "/10/-5", "/10/"])
|
ucmd.args(&["numbers50.txt", "/10/-5", "/10/"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("csplit: '/10/': match not found")
|
.stderr_is("csplit: '/10/': match not found\n")
|
||||||
.stdout_is("8\n133\n");
|
.stdout_is("8\n133\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
|
@ -1196,7 +1196,7 @@ fn test_corner_case3() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "/15/-3", "14", "/15/"])
|
ucmd.args(&["numbers50.txt", "/15/-3", "14", "/15/"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("csplit: '/15/': match not found")
|
.stderr_is("csplit: '/15/': match not found\n")
|
||||||
.stdout_is("24\n6\n111\n");
|
.stdout_is("24\n6\n111\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
|
@ -1228,7 +1228,7 @@ fn test_up_to_match_context_underflow() {
|
||||||
ucmd.args(&["numbers50.txt", "/5/-10"])
|
ucmd.args(&["numbers50.txt", "/5/-10"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("0\n141\n")
|
.stdout_is("0\n141\n")
|
||||||
.stderr_is("csplit: '/5/-10': line number out of range");
|
.stderr_is("csplit: '/5/-10': line number out of range\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -1239,7 +1239,7 @@ fn test_up_to_match_context_underflow() {
|
||||||
ucmd.args(&["numbers50.txt", "/5/-10", "-k"])
|
ucmd.args(&["numbers50.txt", "/5/-10", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_is("0\n141\n")
|
.stdout_is("0\n141\n")
|
||||||
.stderr_is("csplit: '/5/-10': line number out of range");
|
.stderr_is("csplit: '/5/-10': line number out of range\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
.expect("counting splits")
|
.expect("counting splits")
|
||||||
|
@ -1256,7 +1256,7 @@ fn test_line_num_range_with_up_to_match1() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "10", "/12/-5"])
|
ucmd.args(&["numbers50.txt", "10", "/12/-5"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("csplit: '/12/-5': line number out of range")
|
.stderr_is("csplit: '/12/-5': line number out of range\n")
|
||||||
.stdout_is("18\n0\n123\n");
|
.stdout_is("18\n0\n123\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
|
@ -1267,7 +1267,7 @@ fn test_line_num_range_with_up_to_match1() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "10", "/12/-5", "-k"])
|
ucmd.args(&["numbers50.txt", "10", "/12/-5", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("csplit: '/12/-5': line number out of range")
|
.stderr_is("csplit: '/12/-5': line number out of range\n")
|
||||||
.stdout_is("18\n0\n123\n");
|
.stdout_is("18\n0\n123\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
|
@ -1286,7 +1286,7 @@ fn test_line_num_range_with_up_to_match2() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "10", "/12/-15"])
|
ucmd.args(&["numbers50.txt", "10", "/12/-15"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("csplit: '/12/-15': line number out of range")
|
.stderr_is("csplit: '/12/-15': line number out of range\n")
|
||||||
.stdout_is("18\n0\n123\n");
|
.stdout_is("18\n0\n123\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
|
@ -1297,7 +1297,7 @@ fn test_line_num_range_with_up_to_match2() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "10", "/12/-15", "-k"])
|
ucmd.args(&["numbers50.txt", "10", "/12/-15", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("csplit: '/12/-15': line number out of range")
|
.stderr_is("csplit: '/12/-15': line number out of range\n")
|
||||||
.stdout_is("18\n0\n123\n");
|
.stdout_is("18\n0\n123\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
|
@ -1315,7 +1315,7 @@ fn test_line_num_range_with_up_to_match3() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
ucmd.args(&["numbers50.txt", "10", "/10/", "-k"])
|
ucmd.args(&["numbers50.txt", "10", "/10/", "-k"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("csplit: '/10/': match not found")
|
.stderr_is("csplit: '/10/': match not found\n")
|
||||||
.stdout_is("18\n123\n");
|
.stdout_is("18\n123\n");
|
||||||
|
|
||||||
let count = glob(&at.plus_as_string("xx*"))
|
let count = glob(&at.plus_as_string("xx*"))
|
||||||
|
|
|
@ -325,7 +325,7 @@ fn test_nocreat_causes_failure_when_outfile_not_present() {
|
||||||
.pipe_in("")
|
.pipe_in("")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only(
|
.stderr_only(
|
||||||
"dd: failed to open 'this-file-does-not-exist.txt': No such file or directory",
|
"dd: failed to open 'this-file-does-not-exist.txt': No such file or directory\n",
|
||||||
);
|
);
|
||||||
assert!(!fix.file_exists(fname));
|
assert!(!fix.file_exists(fname));
|
||||||
}
|
}
|
||||||
|
@ -1286,12 +1286,12 @@ fn test_invalid_number_arg_gnu_compatibility() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&[format!("{}=", command)])
|
.args(&[format!("{}=", command)])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("dd: invalid number: ‘’");
|
.stderr_is("dd: invalid number: ‘’\n");
|
||||||
|
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&[format!("{}=29d", command)])
|
.args(&[format!("{}=29d", command)])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("dd: invalid number: ‘29d’");
|
.stderr_is("dd: invalid number: ‘29d’\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1317,19 +1317,19 @@ fn test_invalid_file_arg_gnu_compatibility() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["if="])
|
.args(&["if="])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("dd: failed to open '': No such file or directory");
|
.stderr_is("dd: failed to open '': No such file or directory\n");
|
||||||
|
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["if=81as9bn8as9g302az8ns9.pdf.zip.pl.com"])
|
.args(&["if=81as9bn8as9g302az8ns9.pdf.zip.pl.com"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is(
|
.stderr_is(
|
||||||
"dd: failed to open '81as9bn8as9g302az8ns9.pdf.zip.pl.com': No such file or directory",
|
"dd: failed to open '81as9bn8as9g302az8ns9.pdf.zip.pl.com': No such file or directory\n",
|
||||||
);
|
);
|
||||||
|
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["of="])
|
.args(&["of="])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("dd: failed to open '': No such file or directory");
|
.stderr_is("dd: failed to open '': No such file or directory\n");
|
||||||
|
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["of=81as9bn8as9g302az8ns9.pdf.zip.pl.com"])
|
.args(&["of=81as9bn8as9g302az8ns9.pdf.zip.pl.com"])
|
||||||
|
|
|
@ -321,13 +321,13 @@ fn test_include_exclude_same_type() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-t", "ext4", "-x", "ext4"])
|
.args(&["-t", "ext4", "-x", "ext4"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("df: file system type 'ext4' both selected and excluded");
|
.stderr_is("df: file system type 'ext4' both selected and excluded\n");
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-t", "ext4", "-x", "ext4", "-t", "ext3", "-x", "ext3"])
|
.args(&["-t", "ext4", "-x", "ext4", "-t", "ext3", "-x", "ext3"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is(
|
.stderr_is(
|
||||||
"df: file system type 'ext4' both selected and excluded\n\
|
"df: file system type 'ext4' both selected and excluded\n\
|
||||||
df: file system type 'ext3' both selected and excluded",
|
df: file system type 'ext3' both selected and excluded\n",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -853,7 +853,7 @@ fn test_nonexistent_file() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("does-not-exist")
|
.arg("does-not-exist")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("df: does-not-exist: No such file or directory");
|
.stderr_only("df: does-not-exist: No such file or directory\n");
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--output=file", "does-not-exist", "."])
|
.args(&["--output=file", "does-not-exist", "."])
|
||||||
.fails()
|
.fails()
|
||||||
|
|
|
@ -99,20 +99,20 @@ fn test_du_invalid_size() {
|
||||||
.arg("/tmp")
|
.arg("/tmp")
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only(format!("du: invalid suffix in --{} argument '1fb4t'", s));
|
.stderr_only(format!("du: invalid suffix in --{} argument '1fb4t'\n", s));
|
||||||
ts.ucmd()
|
ts.ucmd()
|
||||||
.arg(format!("--{}=x", s))
|
.arg(format!("--{}=x", s))
|
||||||
.arg("/tmp")
|
.arg("/tmp")
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only(format!("du: invalid --{} argument 'x'", s));
|
.stderr_only(format!("du: invalid --{} argument 'x'\n", s));
|
||||||
#[cfg(not(target_pointer_width = "128"))]
|
#[cfg(not(target_pointer_width = "128"))]
|
||||||
ts.ucmd()
|
ts.ucmd()
|
||||||
.arg(format!("--{}=1Y", s))
|
.arg(format!("--{}=1Y", s))
|
||||||
.arg("/tmp")
|
.arg("/tmp")
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only(format!("du: --{} argument '1Y' too large", s));
|
.stderr_only(format!("du: --{} argument '1Y' too large\n", s));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ fn test_unset_invalid_variables() {
|
||||||
// with this error: Error { kind: InvalidInput, message: "nul byte found in provided data" }
|
// with this error: Error { kind: InvalidInput, message: "nul byte found in provided data" }
|
||||||
for var in ["", "a=b"] {
|
for var in ["", "a=b"] {
|
||||||
new_ucmd!().arg("-u").arg(var).run().stderr_only(format!(
|
new_ucmd!().arg("-u").arg(var).run().stderr_only(format!(
|
||||||
"env: cannot unset {}: Invalid argument",
|
"env: cannot unset {}: Invalid argument\n",
|
||||||
var.quote()
|
var.quote()
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ fn test_empty_name() {
|
||||||
.arg("-i")
|
.arg("-i")
|
||||||
.arg("=xyz")
|
.arg("=xyz")
|
||||||
.run()
|
.run()
|
||||||
.stderr_only("env: warning: no name specified for value 'xyz'");
|
.stderr_only("env: warning: no name specified for value 'xyz'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -134,7 +134,7 @@ fn test_check_file_not_found_warning() {
|
||||||
.arg(at.subdir.join("testf.sha1"))
|
.arg(at.subdir.join("testf.sha1"))
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_is("sha1sum: testf: No such file or directory\ntestf: FAILED open or read\n")
|
.stdout_is("sha1sum: testf: No such file or directory\ntestf: FAILED open or read\n")
|
||||||
.stderr_is("sha1sum: warning: 1 listed file could not be read");
|
.stderr_is("sha1sum: warning: 1 listed file could not be read\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -288,21 +288,21 @@ fn test_head_invalid_num() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-c", "1024R", "emptyfile.txt"])
|
.args(&["-c", "1024R", "emptyfile.txt"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("head: invalid number of bytes: '1024R'");
|
.stderr_is("head: invalid number of bytes: '1024R'\n");
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-n", "1024R", "emptyfile.txt"])
|
.args(&["-n", "1024R", "emptyfile.txt"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("head: invalid number of lines: '1024R'");
|
.stderr_is("head: invalid number of lines: '1024R'\n");
|
||||||
#[cfg(not(target_pointer_width = "128"))]
|
#[cfg(not(target_pointer_width = "128"))]
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-c", "1Y", "emptyfile.txt"])
|
.args(&["-c", "1Y", "emptyfile.txt"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("head: invalid number of bytes: '1Y': Value too large for defined data type");
|
.stderr_is("head: invalid number of bytes: '1Y': Value too large for defined data type\n");
|
||||||
#[cfg(not(target_pointer_width = "128"))]
|
#[cfg(not(target_pointer_width = "128"))]
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-n", "1Y", "emptyfile.txt"])
|
.args(&["-n", "1Y", "emptyfile.txt"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("head: invalid number of lines: '1Y': Value too large for defined data type");
|
.stderr_is("head: invalid number of lines: '1Y': Value too large for defined data type\n");
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
{
|
{
|
||||||
let sizes = ["1000G", "10T"];
|
let sizes = ["1000G", "10T"];
|
||||||
|
@ -317,13 +317,13 @@ fn test_head_invalid_num() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-c", size])
|
.args(&["-c", size])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("head: out of range integral type conversion attempted: number of bytes is too large");
|
.stderr_is("head: out of range integral type conversion attempted: number of bytes is too large\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-c", "-³"])
|
.args(&["-c", "-³"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("head: invalid number of bytes: '³'");
|
.stderr_is("head: invalid number of bytes: '³'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -206,7 +206,7 @@ fn tab_multi_character() {
|
||||||
.arg("-t")
|
.arg("-t")
|
||||||
.arg("э")
|
.arg("э")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("join: multi-character tab э");
|
.stderr_is("join: multi-character tab э\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -282,7 +282,7 @@ fn empty_format() {
|
||||||
.arg("-o")
|
.arg("-o")
|
||||||
.arg("")
|
.arg("")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("join: invalid file number in field spec: ''");
|
.stderr_is("join: invalid file number in field spec: ''\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -332,7 +332,7 @@ fn wrong_line_order() {
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_contains("7 g f 4 fg")
|
.stdout_contains("7 g f 4 fg")
|
||||||
.stderr_is(&format!(
|
.stderr_is(&format!(
|
||||||
"{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order",
|
"{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order\n",
|
||||||
ts.bin_path.to_string_lossy(),
|
ts.bin_path.to_string_lossy(),
|
||||||
ts.util_name
|
ts.util_name
|
||||||
));
|
));
|
||||||
|
@ -344,7 +344,7 @@ fn wrong_line_order() {
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_does_not_contain("7 g f 4 fg")
|
.stdout_does_not_contain("7 g f 4 fg")
|
||||||
.stderr_is(&format!(
|
.stderr_is(&format!(
|
||||||
"{0}: fields_4.txt:5: is not sorted: 11 g 5 gh",
|
"{0}: fields_4.txt:5: is not sorted: 11 g 5 gh\n",
|
||||||
ts.util_name
|
ts.util_name
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -358,7 +358,7 @@ fn both_files_wrong_line_order() {
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_contains("5 e 3 ef")
|
.stdout_contains("5 e 3 ef")
|
||||||
.stderr_is(&format!(
|
.stderr_is(&format!(
|
||||||
"{0} {1}: fields_5.txt:4: is not sorted: 3\n{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order",
|
"{0} {1}: fields_5.txt:4: is not sorted: 3\n{0} {1}: fields_4.txt:5: is not sorted: 11 g 5 gh\n{0} {1}: input is not in sorted order\n",
|
||||||
ts.bin_path.to_string_lossy(),
|
ts.bin_path.to_string_lossy(),
|
||||||
ts.util_name
|
ts.util_name
|
||||||
));
|
));
|
||||||
|
@ -370,7 +370,7 @@ fn both_files_wrong_line_order() {
|
||||||
.fails()
|
.fails()
|
||||||
.stdout_does_not_contain("5 e 3 ef")
|
.stdout_does_not_contain("5 e 3 ef")
|
||||||
.stderr_is(&format!(
|
.stderr_is(&format!(
|
||||||
"{0}: fields_5.txt:4: is not sorted: 3",
|
"{0}: fields_5.txt:4: is not sorted: 3\n",
|
||||||
ts.util_name
|
ts.util_name
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -453,7 +453,7 @@ fn non_unicode() {
|
||||||
.arg("non-unicode_2.bin")
|
.arg("non-unicode_2.bin")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is(
|
.stderr_is(
|
||||||
"join: unprintable field separators are only supported on unix-like platforms",
|
"join: unprintable field separators are only supported on unix-like platforms\n",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ fn test_link_no_circular() {
|
||||||
|
|
||||||
ucmd.args(&[link, link])
|
ucmd.args(&[link, link])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("link: cannot create link 'test_link_no_circular' to 'test_link_no_circular': No such file or directory");
|
.stderr_is("link: cannot create link 'test_link_no_circular' to 'test_link_no_circular': No such file or directory\n");
|
||||||
assert!(!at.file_exists(link));
|
assert!(!at.file_exists(link));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ fn test_link_nonexistent_file() {
|
||||||
|
|
||||||
ucmd.args(&[file, link])
|
ucmd.args(&[file, link])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("link: cannot create link 'test_link_nonexistent_file_link' to 'test_link_nonexistent_file': No such file or directory");
|
.stderr_only("link: cannot create link 'test_link_nonexistent_file_link' to 'test_link_nonexistent_file': No such file or directory\n");
|
||||||
assert!(!at.file_exists(file));
|
assert!(!at.file_exists(file));
|
||||||
assert!(!at.file_exists(link));
|
assert!(!at.file_exists(link));
|
||||||
}
|
}
|
||||||
|
|
|
@ -441,7 +441,7 @@ fn test_symlink_missing_destination() {
|
||||||
at.touch(file);
|
at.touch(file);
|
||||||
|
|
||||||
ucmd.args(&["-s", "-T", file]).fails().stderr_is(format!(
|
ucmd.args(&["-s", "-T", file]).fails().stderr_is(format!(
|
||||||
"ln: missing destination file operand after '{}'",
|
"ln: missing destination file operand after '{}'\n",
|
||||||
file
|
file
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -685,7 +685,7 @@ fn test_ls_width() {
|
||||||
.args(&option.split(' ').collect::<Vec<_>>())
|
.args(&option.split(' ').collect::<Vec<_>>())
|
||||||
.arg("-C")
|
.arg("-C")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("ls: invalid line width: '1a'");
|
.stderr_only("ls: invalid line width: '1a'\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -736,7 +736,7 @@ fn test_ls_columns() {
|
||||||
.arg("-C")
|
.arg("-C")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_is("test-columns-1 test-columns-2 test-columns-3 test-columns-4\n")
|
.stdout_is("test-columns-1 test-columns-2 test-columns-3 test-columns-4\n")
|
||||||
.stderr_is("ls: ignoring invalid width in environment variable COLUMNS: 'garbage'");
|
.stderr_is("ls: ignoring invalid width in environment variable COLUMNS: 'garbage'\n");
|
||||||
}
|
}
|
||||||
scene
|
scene
|
||||||
.ucmd()
|
.ucmd()
|
||||||
|
|
|
@ -7,7 +7,7 @@ fn test_invalid_arg() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_create_fifo_missing_operand() {
|
fn test_create_fifo_missing_operand() {
|
||||||
new_ucmd!().fails().stderr_is("mkfifo: missing operand");
|
new_ucmd!().fails().stderr_is("mkfifo: missing operand\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -46,5 +46,5 @@ fn test_create_one_fifo_already_exists() {
|
||||||
.arg("abcdef")
|
.arg("abcdef")
|
||||||
.arg("abcdef")
|
.arg("abcdef")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("mkfifo: cannot create fifo 'abcdef': File exists");
|
.stderr_is("mkfifo: cannot create fifo 'abcdef': File exists\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -275,7 +275,7 @@ fn test_mv_same_file_not_dot_dir() {
|
||||||
|
|
||||||
at.mkdir(dir);
|
at.mkdir(dir);
|
||||||
ucmd.arg(dir).arg(dir).fails().stderr_is(format!(
|
ucmd.arg(dir).arg(dir).fails().stderr_is(format!(
|
||||||
"mv: cannot move '{d}' to a subdirectory of itself, '{d}/{d}'",
|
"mv: cannot move '{d}' to a subdirectory of itself, '{d}/{d}'\n",
|
||||||
d = dir,
|
d = dir,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ fn test_from_iec_i_requires_suffix() {
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(2)
|
.code_is(2)
|
||||||
.stderr_is(format!(
|
.stderr_is(format!(
|
||||||
"numfmt: missing 'i' suffix in input: '{}' (e.g Ki/Mi/Gi)",
|
"numfmt: missing 'i' suffix in input: '{}' (e.g Ki/Mi/Gi)\n",
|
||||||
number
|
number
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ fn test_header_error_if_non_numeric() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--header=two"])
|
.args(&["--header=two"])
|
||||||
.run()
|
.run()
|
||||||
.stderr_is("numfmt: invalid header value 'two'");
|
.stderr_is("numfmt: invalid header value 'two'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -159,7 +159,7 @@ fn test_header_error_if_0() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--header=0"])
|
.args(&["--header=0"])
|
||||||
.run()
|
.run()
|
||||||
.stderr_is("numfmt: invalid header value '0'");
|
.stderr_is("numfmt: invalid header value '0'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -167,7 +167,7 @@ fn test_header_error_if_negative() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--header=-3"])
|
.args(&["--header=-3"])
|
||||||
.run()
|
.run()
|
||||||
.stderr_is("numfmt: invalid header value '-3'");
|
.stderr_is("numfmt: invalid header value '-3'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -458,7 +458,7 @@ fn test_delimiter_must_not_be_more_than_one_character() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--delimiter", "sad"])
|
.args(&["--delimiter", "sad"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("numfmt: the delimiter must be a single character");
|
.stderr_is("numfmt: the delimiter must be a single character\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -854,7 +854,7 @@ fn test_od_invalid_bytes() {
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only(format!(
|
.stderr_only(format!(
|
||||||
"od: invalid {} argument '{}'",
|
"od: invalid {} argument '{}'\n",
|
||||||
option, INVALID_SIZE
|
option, INVALID_SIZE
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -864,7 +864,7 @@ fn test_od_invalid_bytes() {
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only(format!(
|
.stderr_only(format!(
|
||||||
"od: invalid suffix in {} argument '{}'",
|
"od: invalid suffix in {} argument '{}'\n",
|
||||||
option, INVALID_SUFFIX
|
option, INVALID_SUFFIX
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -874,6 +874,9 @@ fn test_od_invalid_bytes() {
|
||||||
.arg("file")
|
.arg("file")
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only(format!("od: {} argument '{}' too large", option, BIG_SIZE));
|
.stderr_only(format!(
|
||||||
|
"od: {} argument '{}' too large\n",
|
||||||
|
option, BIG_SIZE
|
||||||
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,7 @@ fn test_with_valid_page_ranges() {
|
||||||
scenario
|
scenario
|
||||||
.args(&["--pages=20:5", test_file_path])
|
.args(&["--pages=20:5", test_file_path])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("pr: invalid --pages argument '20:5'")
|
.stderr_is("pr: invalid --pages argument '20:5'\n")
|
||||||
.stdout_is("");
|
.stdout_is("");
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--pages=1:5", test_file_path])
|
.args(&["--pages=1:5", test_file_path])
|
||||||
|
@ -172,17 +172,17 @@ fn test_with_valid_page_ranges() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--pages=-1:5", test_file_path])
|
.args(&["--pages=-1:5", test_file_path])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("pr: invalid --pages argument '-1:5'")
|
.stderr_is("pr: invalid --pages argument '-1:5'\n")
|
||||||
.stdout_is("");
|
.stdout_is("");
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--pages=1:-5", test_file_path])
|
.args(&["--pages=1:-5", test_file_path])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("pr: invalid --pages argument '1:-5'")
|
.stderr_is("pr: invalid --pages argument '1:-5'\n")
|
||||||
.stdout_is("");
|
.stdout_is("");
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--pages=5:1", test_file_path])
|
.args(&["--pages=5:1", test_file_path])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("pr: invalid --pages argument '5:1'")
|
.stderr_is("pr: invalid --pages argument '5:1'\n")
|
||||||
.stdout_is("");
|
.stdout_is("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,13 +364,13 @@ fn test_with_mpr_and_column_options() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--column=2", "-m", "-n", test_file_path])
|
.args(&["--column=2", "-m", "-n", test_file_path])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("pr: cannot specify number of columns when printing in parallel")
|
.stderr_is("pr: cannot specify number of columns when printing in parallel\n")
|
||||||
.stdout_is("");
|
.stdout_is("");
|
||||||
|
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-a", "-m", "-n", test_file_path])
|
.args(&["-a", "-m", "-n", test_file_path])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("pr: cannot specify both printing across and printing in parallel")
|
.stderr_is("pr: cannot specify both printing across and printing in parallel\n")
|
||||||
.stdout_is("");
|
.stdout_is("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -239,7 +239,7 @@ fn test_realpath_when_symlink_is_absolute_and_enoent() {
|
||||||
.run()
|
.run()
|
||||||
.stdout_contains("\\dir2\\bar\n")
|
.stdout_contains("\\dir2\\bar\n")
|
||||||
.stdout_contains("\\dir2\\baz\n")
|
.stdout_contains("\\dir2\\baz\n")
|
||||||
.stderr_is("realpath: dir1/foo2: No such file or directory");
|
.stderr_is("realpath: dir1/foo2: No such file or directory\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -503,11 +503,8 @@ fn test_rm_force_prompts_order() {
|
||||||
child.try_write_in(yes.as_bytes()).unwrap();
|
child.try_write_in(yes.as_bytes()).unwrap();
|
||||||
|
|
||||||
let result = child.wait().unwrap();
|
let result = child.wait().unwrap();
|
||||||
let string_output = result.stderr_str();
|
result.stderr_only("rm: remove regular empty file 'empty'? ");
|
||||||
assert_eq!(
|
|
||||||
string_output.trim(),
|
|
||||||
"rm: remove regular empty file 'empty'?"
|
|
||||||
);
|
|
||||||
assert!(!at.file_exists(empty_file));
|
assert!(!at.file_exists(empty_file));
|
||||||
|
|
||||||
at.touch(empty_file);
|
at.touch(empty_file);
|
||||||
|
|
|
@ -57,7 +57,7 @@ fn test_rmdir_nonempty_directory_no_parents() {
|
||||||
|
|
||||||
ucmd.arg(DIR)
|
ucmd.arg(DIR)
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is(format!("rmdir: failed to remove 'dir': {}", NOT_EMPTY));
|
.stderr_is(format!("rmdir: failed to remove 'dir': {}\n", NOT_EMPTY));
|
||||||
|
|
||||||
assert!(at.dir_exists(DIR));
|
assert!(at.dir_exists(DIR));
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ fn test_rmdir_nonempty_directory_with_parents() {
|
||||||
at.touch(NESTED_DIR_FILE);
|
at.touch(NESTED_DIR_FILE);
|
||||||
|
|
||||||
ucmd.arg("-p").arg(NESTED_DIR).fails().stderr_is(format!(
|
ucmd.arg("-p").arg(NESTED_DIR).fails().stderr_is(format!(
|
||||||
"rmdir: failed to remove 'dir/ect/ory': {}",
|
"rmdir: failed to remove 'dir/ect/ory': {}\n",
|
||||||
NOT_EMPTY
|
NOT_EMPTY
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -119,7 +119,7 @@ fn test_rmdir_not_a_directory() {
|
||||||
.fails()
|
.fails()
|
||||||
.no_stdout()
|
.no_stdout()
|
||||||
.stderr_is(format!(
|
.stderr_is(format!(
|
||||||
"rmdir: failed to remove 'file': {}",
|
"rmdir: failed to remove 'file': {}\n",
|
||||||
NOT_A_DIRECTORY
|
NOT_A_DIRECTORY
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ fn test_verbose_multi() {
|
||||||
rmdir: removing directory, 'dir'\n",
|
rmdir: removing directory, 'dir'\n",
|
||||||
)
|
)
|
||||||
.stderr_is(format!(
|
.stderr_is(format!(
|
||||||
"rmdir: failed to remove 'does_not_exist': {}",
|
"rmdir: failed to remove 'does_not_exist': {}\n",
|
||||||
NOT_FOUND
|
NOT_FOUND
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,10 @@ fn test_verbose_nested_failure() {
|
||||||
"rmdir: removing directory, 'dir/ect/ory'\n\
|
"rmdir: removing directory, 'dir/ect/ory'\n\
|
||||||
rmdir: removing directory, 'dir/ect'\n",
|
rmdir: removing directory, 'dir/ect'\n",
|
||||||
)
|
)
|
||||||
.stderr_is(format!("rmdir: failed to remove 'dir/ect': {}", NOT_EMPTY));
|
.stderr_is(format!(
|
||||||
|
"rmdir: failed to remove 'dir/ect': {}\n",
|
||||||
|
NOT_EMPTY
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
|
@ -211,7 +214,7 @@ fn test_rmdir_remove_symlink_file() {
|
||||||
at.symlink_file("file", "fl");
|
at.symlink_file("file", "fl");
|
||||||
|
|
||||||
ucmd.arg("fl/").fails().stderr_is(format!(
|
ucmd.arg("fl/").fails().stderr_is(format!(
|
||||||
"rmdir: failed to remove 'fl/': {}",
|
"rmdir: failed to remove 'fl/': {}\n",
|
||||||
NOT_A_DIRECTORY
|
NOT_A_DIRECTORY
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -227,7 +230,7 @@ fn test_rmdir_remove_symlink_dir() {
|
||||||
|
|
||||||
ucmd.arg("dl/")
|
ucmd.arg("dl/")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("rmdir: failed to remove 'dl/': Symbolic link not followed");
|
.stderr_is("rmdir: failed to remove 'dl/': Symbolic link not followed\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||||
|
@ -239,5 +242,5 @@ fn test_rmdir_remove_symlink_dangling() {
|
||||||
|
|
||||||
ucmd.arg("dl/")
|
ucmd.arg("dl/")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("rmdir: failed to remove 'dl/': Symbolic link not followed");
|
.stderr_is("rmdir: failed to remove 'dl/': Symbolic link not followed\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,14 +63,14 @@ fn test_invalid_buffer_size() {
|
||||||
.arg("asd")
|
.arg("asd")
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(2)
|
.code_is(2)
|
||||||
.stderr_only("sort: invalid --buffer-size argument 'asd'");
|
.stderr_only("sort: invalid --buffer-size argument 'asd'\n");
|
||||||
|
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("-S")
|
.arg("-S")
|
||||||
.arg("100f")
|
.arg("100f")
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(2)
|
.code_is(2)
|
||||||
.stderr_only("sort: invalid suffix in --buffer-size argument '100f'");
|
.stderr_only("sort: invalid suffix in --buffer-size argument '100f'\n");
|
||||||
|
|
||||||
#[cfg(not(target_pointer_width = "128"))]
|
#[cfg(not(target_pointer_width = "128"))]
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
|
@ -80,7 +80,7 @@ fn test_invalid_buffer_size() {
|
||||||
.arg("ext_sort.txt")
|
.arg("ext_sort.txt")
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(2)
|
.code_is(2)
|
||||||
.stderr_only("sort: --buffer-size argument '1Y' too large");
|
.stderr_only("sort: --buffer-size argument '1Y' too large\n");
|
||||||
|
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
{
|
{
|
||||||
|
@ -94,7 +94,7 @@ fn test_invalid_buffer_size() {
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(2)
|
.code_is(2)
|
||||||
.stderr_only(format!(
|
.stderr_only(format!(
|
||||||
"sort: --buffer-size argument '{}' too large",
|
"sort: --buffer-size argument '{}' too large\n",
|
||||||
buffer_size
|
buffer_size
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -529,7 +529,7 @@ fn test_keys_invalid_field() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-k", "1."])
|
.args(&["-k", "1."])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("sort: failed to parse key '1.': failed to parse character index '': cannot parse integer from empty string");
|
.stderr_only("sort: failed to parse key '1.': failed to parse character index '': cannot parse integer from empty string\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -537,7 +537,7 @@ fn test_keys_invalid_field_option() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-k", "1.1x"])
|
.args(&["-k", "1.1x"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("sort: failed to parse key '1.1x': invalid option: 'x'");
|
.stderr_only("sort: failed to parse key '1.1x': invalid option: 'x'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -545,7 +545,7 @@ fn test_keys_invalid_field_zero() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-k", "0.1"])
|
.args(&["-k", "0.1"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("sort: failed to parse key '0.1': field index can not be 0");
|
.stderr_only("sort: failed to parse key '0.1': field index can not be 0\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -553,7 +553,7 @@ fn test_keys_invalid_char_zero() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-k", "1.0"])
|
.args(&["-k", "1.0"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("sort: failed to parse key '1.0': invalid character index 0 for the start position of a field");
|
.stderr_only("sort: failed to parse key '1.0': invalid character index 0 for the start position of a field\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -801,7 +801,7 @@ fn test_check_unique() {
|
||||||
.pipe_in("A\nA\n")
|
.pipe_in("A\nA\n")
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("sort: -:2: disorder: A");
|
.stderr_only("sort: -:2: disorder: A\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -847,9 +847,9 @@ fn test_nonexistent_file() {
|
||||||
.code_is(2)
|
.code_is(2)
|
||||||
.stderr_only(
|
.stderr_only(
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
"sort: cannot read: nonexistent.txt: No such file or directory",
|
"sort: cannot read: nonexistent.txt: No such file or directory\n",
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
"sort: cannot read: nonexistent.txt: The system cannot find the file specified.",
|
"sort: cannot read: nonexistent.txt: The system cannot find the file specified.\n",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -928,7 +928,7 @@ fn test_compress_fail() {
|
||||||
"10",
|
"10",
|
||||||
])
|
])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("sort: couldn't execute compress program: errno 2");
|
.stderr_only("sort: couldn't execute compress program: errno 2\n");
|
||||||
// With coverage, it fails with a different error:
|
// With coverage, it fails with a different error:
|
||||||
// "thread 'main' panicked at 'called `Option::unwrap()` on ...
|
// "thread 'main' panicked at 'called `Option::unwrap()` on ...
|
||||||
// So, don't check the output
|
// So, don't check the output
|
||||||
|
@ -1018,9 +1018,9 @@ fn test_verifies_out_file() {
|
||||||
.code_is(2)
|
.code_is(2)
|
||||||
.stderr_only(
|
.stderr_only(
|
||||||
#[cfg(not(windows))]
|
#[cfg(not(windows))]
|
||||||
"sort: open failed: nonexistent_dir/nonexistent_file: No such file or directory",
|
"sort: open failed: nonexistent_dir/nonexistent_file: No such file or directory\n",
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
"sort: open failed: nonexistent_dir/nonexistent_file: The system cannot find the path specified.",
|
"sort: open failed: nonexistent_dir/nonexistent_file: The system cannot find the path specified.\n",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1047,7 +1047,7 @@ fn test_verifies_input_files() {
|
||||||
.args(&["/dev/random", "nonexistent_file"])
|
.args(&["/dev/random", "nonexistent_file"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(2)
|
.code_is(2)
|
||||||
.stderr_is("sort: cannot read: nonexistent_file: No such file or directory");
|
.stderr_is("sort: cannot read: nonexistent_file: No such file or directory\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -320,7 +320,7 @@ fn test_split_lines_number() {
|
||||||
.args(&["--lines", "2fb", "file"])
|
.args(&["--lines", "2fb", "file"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("split: invalid number of lines: '2fb'");
|
.stderr_only("split: invalid number of lines: '2fb'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -329,13 +329,15 @@ fn test_split_invalid_bytes_size() {
|
||||||
.args(&["-b", "1024R"])
|
.args(&["-b", "1024R"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("split: invalid number of bytes: '1024R'");
|
.stderr_only("split: invalid number of bytes: '1024R'\n");
|
||||||
#[cfg(not(target_pointer_width = "128"))]
|
#[cfg(not(target_pointer_width = "128"))]
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-b", "1Y"])
|
.args(&["-b", "1Y"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("split: invalid number of bytes: '1Y': Value too large for defined data type");
|
.stderr_only(
|
||||||
|
"split: invalid number of bytes: '1Y': Value too large for defined data type\n",
|
||||||
|
);
|
||||||
#[cfg(target_pointer_width = "32")]
|
#[cfg(target_pointer_width = "32")]
|
||||||
{
|
{
|
||||||
let sizes = ["1000G", "10T"];
|
let sizes = ["1000G", "10T"];
|
||||||
|
@ -357,7 +359,7 @@ fn test_split_chunks_num_chunks_oversized_32() {
|
||||||
.args(&["--number", "5000000000", "file"])
|
.args(&["--number", "5000000000", "file"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("split: Number of chunks too big");
|
.stderr_only("split: Number of chunks too big\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,7 +369,7 @@ fn test_split_stdin_num_chunks() {
|
||||||
.args(&["--number=1"])
|
.args(&["--number=1"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("split: -: cannot determine file size");
|
.stderr_only("split: -: cannot determine file size\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn file_read(at: &AtPath, filename: &str) -> String {
|
fn file_read(at: &AtPath, filename: &str) -> String {
|
||||||
|
@ -457,7 +459,7 @@ fn test_suffixes_exhausted() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["-b", "1", "-a", "1", "asciilowercase.txt"])
|
.args(&["-b", "1", "-a", "1", "asciilowercase.txt"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("split: output file suffixes exhausted");
|
.stderr_only("split: output file suffixes exhausted\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -699,7 +701,7 @@ fn test_guard_input() {
|
||||||
ts.ucmd()
|
ts.ucmd()
|
||||||
.args(&["-C", "6", "xaa"])
|
.args(&["-C", "6", "xaa"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("split: 'xaa' would overwrite input; aborting");
|
.stderr_only("split: 'xaa' would overwrite input; aborting\n");
|
||||||
assert_eq!(at.read("xaa"), "1\n2\n3\n");
|
assert_eq!(at.read("xaa"), "1\n2\n3\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,7 +61,7 @@ fn test_stdbuf_invalid_mode_fails() {
|
||||||
.args(&[*option, "1024R", "head"])
|
.args(&[*option, "1024R", "head"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(125)
|
.code_is(125)
|
||||||
.stderr_only("stdbuf: invalid mode '1024R'");
|
.stderr_only("stdbuf: invalid mode '1024R'\n");
|
||||||
#[cfg(not(target_pointer_width = "128"))]
|
#[cfg(not(target_pointer_width = "128"))]
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&[*option, "1Y", "head"])
|
.args(&[*option, "1Y", "head"])
|
||||||
|
|
|
@ -64,7 +64,7 @@ fn test_invalid_file() {
|
||||||
|
|
||||||
at.mkdir("a");
|
at.mkdir("a");
|
||||||
|
|
||||||
ucmd.arg("a").fails().stderr_is("sum: a: Is a directory");
|
ucmd.arg("a").fails().stderr_is("sum: a: Is a directory\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -73,5 +73,5 @@ fn test_invalid_metadata() {
|
||||||
|
|
||||||
ucmd.arg("b")
|
ucmd.arg("b")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("sum: b: No such file or directory");
|
.stderr_is("sum: b: No such file or directory\n");
|
||||||
}
|
}
|
||||||
|
|
|
@ -269,7 +269,7 @@ fn test_follow_redirect_stdin_name_retry() {
|
||||||
.args(&args)
|
.args(&args)
|
||||||
.fails()
|
.fails()
|
||||||
.no_stdout()
|
.no_stdout()
|
||||||
.stderr_is("tail: cannot follow '-' by name")
|
.stderr_is("tail: cannot follow '-' by name\n")
|
||||||
.code_is(1);
|
.code_is(1);
|
||||||
args.pop();
|
args.pop();
|
||||||
}
|
}
|
||||||
|
@ -295,14 +295,14 @@ fn test_stdin_redirect_dir() {
|
||||||
.set_stdin(File::open(at.plus("dir")).unwrap())
|
.set_stdin(File::open(at.plus("dir")).unwrap())
|
||||||
.fails()
|
.fails()
|
||||||
.no_stdout()
|
.no_stdout()
|
||||||
.stderr_is("tail: error reading 'standard input': Is a directory")
|
.stderr_is("tail: error reading 'standard input': Is a directory\n")
|
||||||
.code_is(1);
|
.code_is(1);
|
||||||
ts.ucmd()
|
ts.ucmd()
|
||||||
.set_stdin(File::open(at.plus("dir")).unwrap())
|
.set_stdin(File::open(at.plus("dir")).unwrap())
|
||||||
.arg("-")
|
.arg("-")
|
||||||
.fails()
|
.fails()
|
||||||
.no_stdout()
|
.no_stdout()
|
||||||
.stderr_is("tail: error reading 'standard input': Is a directory")
|
.stderr_is("tail: error reading 'standard input': Is a directory\n")
|
||||||
.code_is(1);
|
.code_is(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,14 +328,14 @@ fn test_stdin_redirect_dir_when_target_os_is_macos() {
|
||||||
.set_stdin(File::open(at.plus("dir")).unwrap())
|
.set_stdin(File::open(at.plus("dir")).unwrap())
|
||||||
.fails()
|
.fails()
|
||||||
.no_stdout()
|
.no_stdout()
|
||||||
.stderr_is("tail: cannot open 'standard input' for reading: No such file or directory")
|
.stderr_is("tail: cannot open 'standard input' for reading: No such file or directory\n")
|
||||||
.code_is(1);
|
.code_is(1);
|
||||||
ts.ucmd()
|
ts.ucmd()
|
||||||
.set_stdin(File::open(at.plus("dir")).unwrap())
|
.set_stdin(File::open(at.plus("dir")).unwrap())
|
||||||
.arg("-")
|
.arg("-")
|
||||||
.fails()
|
.fails()
|
||||||
.no_stdout()
|
.no_stdout()
|
||||||
.stderr_is("tail: cannot open 'standard input' for reading: No such file or directory")
|
.stderr_is("tail: cannot open 'standard input' for reading: No such file or directory\n")
|
||||||
.code_is(1);
|
.code_is(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ fn test_follow_stdin_name_retry() {
|
||||||
.args(&args)
|
.args(&args)
|
||||||
.run()
|
.run()
|
||||||
.no_stdout()
|
.no_stdout()
|
||||||
.stderr_is("tail: cannot follow '-' by name")
|
.stderr_is("tail: cannot follow '-' by name\n")
|
||||||
.code_is(1);
|
.code_is(1);
|
||||||
args.pop();
|
args.pop();
|
||||||
}
|
}
|
||||||
|
@ -827,7 +827,7 @@ fn test_multiple_input_files_missing() {
|
||||||
.stdout_is_fixture("foobar_follow_multiple.expected")
|
.stdout_is_fixture("foobar_follow_multiple.expected")
|
||||||
.stderr_is(
|
.stderr_is(
|
||||||
"tail: cannot open 'missing1' for reading: No such file or directory\n\
|
"tail: cannot open 'missing1' for reading: No such file or directory\n\
|
||||||
tail: cannot open 'missing2' for reading: No such file or directory",
|
tail: cannot open 'missing2' for reading: No such file or directory\n",
|
||||||
)
|
)
|
||||||
.code_is(1);
|
.code_is(1);
|
||||||
}
|
}
|
||||||
|
@ -845,7 +845,7 @@ fn test_follow_missing() {
|
||||||
.no_stdout()
|
.no_stdout()
|
||||||
.stderr_is(
|
.stderr_is(
|
||||||
"tail: cannot open 'missing' for reading: No such file or directory\n\
|
"tail: cannot open 'missing' for reading: No such file or directory\n\
|
||||||
tail: no files remaining",
|
tail: no files remaining\n",
|
||||||
)
|
)
|
||||||
.code_is(1);
|
.code_is(1);
|
||||||
}
|
}
|
||||||
|
@ -861,7 +861,7 @@ fn test_follow_name_stdin() {
|
||||||
.arg("--follow=name")
|
.arg("--follow=name")
|
||||||
.arg("-")
|
.arg("-")
|
||||||
.run()
|
.run()
|
||||||
.stderr_is("tail: cannot follow '-' by name")
|
.stderr_is("tail: cannot follow '-' by name\n")
|
||||||
.code_is(1);
|
.code_is(1);
|
||||||
ts.ucmd()
|
ts.ucmd()
|
||||||
.arg("--follow=name")
|
.arg("--follow=name")
|
||||||
|
@ -869,7 +869,7 @@ fn test_follow_name_stdin() {
|
||||||
.arg("-")
|
.arg("-")
|
||||||
.arg("FILE2")
|
.arg("FILE2")
|
||||||
.run()
|
.run()
|
||||||
.stderr_is("tail: cannot follow '-' by name")
|
.stderr_is("tail: cannot follow '-' by name\n")
|
||||||
.code_is(1);
|
.code_is(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2523,7 +2523,7 @@ fn test_no_such_file() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("missing")
|
.arg("missing")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("tail: cannot open 'missing' for reading: No such file or directory")
|
.stderr_is("tail: cannot open 'missing' for reading: No such file or directory\n")
|
||||||
.no_stdout()
|
.no_stdout()
|
||||||
.code_is(1);
|
.code_is(1);
|
||||||
}
|
}
|
||||||
|
@ -3448,7 +3448,7 @@ fn test_when_argument_file_is_a_directory() {
|
||||||
let at = &ts.fixtures;
|
let at = &ts.fixtures;
|
||||||
at.mkdir("dir");
|
at.mkdir("dir");
|
||||||
|
|
||||||
let expected = "tail: error reading 'dir': Is a directory";
|
let expected = "tail: error reading 'dir': Is a directory\n";
|
||||||
ts.ucmd()
|
ts.ucmd()
|
||||||
.arg("dir")
|
.arg("dir")
|
||||||
.fails()
|
.fails()
|
||||||
|
@ -3486,7 +3486,7 @@ fn test_when_argument_file_is_a_symlink() {
|
||||||
|
|
||||||
at.symlink_file("dir", "dir_link");
|
at.symlink_file("dir", "dir_link");
|
||||||
|
|
||||||
let expected = "tail: error reading 'dir_link': Is a directory";
|
let expected = "tail: error reading 'dir_link': Is a directory\n";
|
||||||
ts.ucmd()
|
ts.ucmd()
|
||||||
.arg("dir_link")
|
.arg("dir_link")
|
||||||
.fails()
|
.fails()
|
||||||
|
@ -3504,7 +3504,7 @@ fn test_when_argument_file_is_a_symlink_to_directory_then_error() {
|
||||||
at.mkdir("dir");
|
at.mkdir("dir");
|
||||||
at.symlink_file("dir", "dir_link");
|
at.symlink_file("dir", "dir_link");
|
||||||
|
|
||||||
let expected = "tail: error reading 'dir_link': Is a directory";
|
let expected = "tail: error reading 'dir_link': Is a directory\n";
|
||||||
ts.ucmd()
|
ts.ucmd()
|
||||||
.arg("dir_link")
|
.arg("dir_link")
|
||||||
.fails()
|
.fails()
|
||||||
|
@ -3562,17 +3562,17 @@ fn test_when_argument_file_is_non_existent_unix_socket_address_then_error() {
|
||||||
|
|
||||||
#[cfg(all(not(target_os = "freebsd"), not(target_os = "macos")))]
|
#[cfg(all(not(target_os = "freebsd"), not(target_os = "macos")))]
|
||||||
let expected_stderr = format!(
|
let expected_stderr = format!(
|
||||||
"tail: cannot open '{}' for reading: No such device or address",
|
"tail: cannot open '{}' for reading: No such device or address\n",
|
||||||
socket
|
socket
|
||||||
);
|
);
|
||||||
#[cfg(target_os = "freebsd")]
|
#[cfg(target_os = "freebsd")]
|
||||||
let expected_stderr = format!(
|
let expected_stderr = format!(
|
||||||
"tail: cannot open '{}' for reading: Operation not supported",
|
"tail: cannot open '{}' for reading: Operation not supported\n",
|
||||||
socket
|
socket
|
||||||
);
|
);
|
||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
let expected_stderr = format!(
|
let expected_stderr = format!(
|
||||||
"tail: cannot open '{}' for reading: Operation not supported on socket",
|
"tail: cannot open '{}' for reading: Operation not supported on socket\n",
|
||||||
socket
|
socket
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -288,7 +288,7 @@ fn test_float_inequality_is_error() {
|
||||||
.args(&["123.45", "-ge", "6"])
|
.args(&["123.45", "-ge", "6"])
|
||||||
.run()
|
.run()
|
||||||
.code_is(2)
|
.code_is(2)
|
||||||
.stderr_is("test: invalid integer '123.45'");
|
.stderr_is("test: invalid integer '123.45'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -306,7 +306,7 @@ fn test_invalid_utf8_integer_compare() {
|
||||||
|
|
||||||
cmd.run()
|
cmd.run()
|
||||||
.code_is(2)
|
.code_is(2)
|
||||||
.stderr_is("test: invalid integer $'fo\\x80o'");
|
.stderr_is("test: invalid integer $'fo\\x80o'\n");
|
||||||
|
|
||||||
let mut cmd = new_ucmd!();
|
let mut cmd = new_ucmd!();
|
||||||
cmd.raw.arg(arg);
|
cmd.raw.arg(arg);
|
||||||
|
@ -314,7 +314,7 @@ fn test_invalid_utf8_integer_compare() {
|
||||||
|
|
||||||
cmd.run()
|
cmd.run()
|
||||||
.code_is(2)
|
.code_is(2)
|
||||||
.stderr_is("test: invalid integer $'fo\\x80o'");
|
.stderr_is("test: invalid integer $'fo\\x80o'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -827,7 +827,7 @@ fn test_erroneous_parenthesized_expression() {
|
||||||
.args(&["a", "!=", "(", "b", "-a", "b", ")", "!=", "c"])
|
.args(&["a", "!=", "(", "b", "-a", "b", ")", "!=", "c"])
|
||||||
.run()
|
.run()
|
||||||
.code_is(2)
|
.code_is(2)
|
||||||
.stderr_is("test: extra argument 'b'");
|
.stderr_is("test: extra argument 'b'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -875,7 +875,7 @@ fn test_bracket_syntax_missing_right_bracket() {
|
||||||
ucmd.args(&["1", "-eq"])
|
ucmd.args(&["1", "-eq"])
|
||||||
.run()
|
.run()
|
||||||
.code_is(2)
|
.code_is(2)
|
||||||
.stderr_is("[: missing ']'");
|
.stderr_is("[: missing ']'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -48,11 +48,11 @@ fn test_verbose() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&[verbose_flag, ".1", "sleep", "10"])
|
.args(&[verbose_flag, ".1", "sleep", "10"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("timeout: sending signal TERM to command 'sleep'");
|
.stderr_only("timeout: sending signal TERM to command 'sleep'\n");
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&[verbose_flag, "-s0", "-k.1", ".1", "sleep", "10"])
|
.args(&[verbose_flag, "-s0", "-k.1", ".1", "sleep", "10"])
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_only("timeout: sending signal EXIT to command 'sleep'\ntimeout: sending signal KILL to command 'sleep'");
|
.stderr_only("timeout: sending signal EXIT to command 'sleep'\ntimeout: sending signal KILL to command 'sleep'\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -712,7 +712,7 @@ fn test_touch_no_such_file_error_msg() {
|
||||||
let path_str = path.to_str().unwrap();
|
let path_str = path.to_str().unwrap();
|
||||||
|
|
||||||
new_ucmd!().arg(&path).fails().stderr_only(format!(
|
new_ucmd!().arg(&path).fails().stderr_only(format!(
|
||||||
"touch: cannot touch '{}': No such file or directory",
|
"touch: cannot touch '{}': No such file or directory\n",
|
||||||
path_str
|
path_str
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -755,7 +755,7 @@ fn test_touch_permission_denied_error_msg() {
|
||||||
|
|
||||||
let full_path = at.plus_as_string(path_str);
|
let full_path = at.plus_as_string(path_str);
|
||||||
ucmd.arg(&full_path).fails().stderr_only(format!(
|
ucmd.arg(&full_path).fails().stderr_only(format!(
|
||||||
"touch: cannot touch '{}': Permission denied",
|
"touch: cannot touch '{}': Permission denied\n",
|
||||||
&full_path
|
&full_path
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
@ -777,7 +777,10 @@ fn check_against_gnu_tr_tests_range_a_a() {
|
||||||
.stdout_is("zbc");
|
.stdout_is("zbc");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Since pr https://github.com/uutils/coreutils/pull/4261:
|
||||||
|
// stderr ends with 2 newlines but expected is only 1.
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg(disabled_until_fixed)]
|
||||||
fn check_against_gnu_tr_tests_null() {
|
fn check_against_gnu_tr_tests_null() {
|
||||||
// ['null', qw(a ''), {IN=>''}, {OUT=>''}, {EXIT=>1},
|
// ['null', qw(a ''), {IN=>''}, {OUT=>''}, {EXIT=>1},
|
||||||
// {ERR=>"$prog: when not truncating set1, string2 must be non-empty\n"}],
|
// {ERR=>"$prog: when not truncating set1, string2 must be non-empty\n"}],
|
||||||
|
@ -852,7 +855,10 @@ fn check_against_gnu_tr_tests_rep_3() {
|
||||||
.stdout_is("1x2");
|
.stdout_is("1x2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Since pr https://github.com/uutils/coreutils/pull/4261:
|
||||||
|
// stderr ends with 2 newlines but expected is only 1.
|
||||||
#[test]
|
#[test]
|
||||||
|
#[cfg(disabled_until_fixed)]
|
||||||
fn check_against_gnu_tr_tests_o_rep_1() {
|
fn check_against_gnu_tr_tests_o_rep_1() {
|
||||||
// # Another couple octal repeat count tests.
|
// # Another couple octal repeat count tests.
|
||||||
// ['o-rep-1', qw('[b*08]' '[x*]'), {IN=>''}, {OUT=>''}, {EXIT=>1},
|
// ['o-rep-1', qw('[b*08]' '[x*]'), {IN=>''}, {OUT=>''}, {EXIT=>1},
|
||||||
|
@ -925,7 +931,7 @@ fn check_against_gnu_tr_tests_bs_at_end() {
|
||||||
.pipe_in(r"\")
|
.pipe_in(r"\")
|
||||||
.succeeds()
|
.succeeds()
|
||||||
.stdout_is("x")
|
.stdout_is("x")
|
||||||
.stderr_is("tr: warning: an unescaped backslash at end of string is not portable");
|
.stderr_is("tr: warning: an unescaped backslash at end of string is not portable\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -938,7 +944,7 @@ fn check_against_gnu_tr_tests_ross_0a() {
|
||||||
.args(&["-cs", "[:upper:]", "X[Y*]"])
|
.args(&["-cs", "[:upper:]", "X[Y*]"])
|
||||||
.pipe_in("")
|
.pipe_in("")
|
||||||
.fails()
|
.fails()
|
||||||
.stderr_is("tr: when translating with complemented character classes,\nstring2 must map all characters in the domain to one");
|
.stderr_is("tr: when translating with complemented character classes,\nstring2 must map all characters in the domain to one\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1026,6 +1032,10 @@ fn check_against_gnu_tr_tests_ross_6() {
|
||||||
.stdout_is("");
|
.stdout_is("");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Since pr https://github.com/uutils/coreutils/pull/4261:
|
||||||
|
// stderr ends with 2 newlines but expected is only 1.
|
||||||
|
#[test]
|
||||||
|
#[cfg(disabled_until_fixed)]
|
||||||
#[test]
|
#[test]
|
||||||
fn check_against_gnu_tr_tests_empty_eq() {
|
fn check_against_gnu_tr_tests_empty_eq() {
|
||||||
// # Ensure that these fail.
|
// # Ensure that these fail.
|
||||||
|
@ -1039,6 +1049,10 @@ fn check_against_gnu_tr_tests_empty_eq() {
|
||||||
.stderr_is("tr: missing equivalence class character '[==]'\n");
|
.stderr_is("tr: missing equivalence class character '[==]'\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: Since pr https://github.com/uutils/coreutils/pull/4261:
|
||||||
|
// stderr ends with 2 newlines but expected is only 1.
|
||||||
|
#[test]
|
||||||
|
#[cfg(disabled_until_fixed)]
|
||||||
#[test]
|
#[test]
|
||||||
fn check_against_gnu_tr_tests_empty_cc() {
|
fn check_against_gnu_tr_tests_empty_cc() {
|
||||||
// ['empty-cc', qw('[::]' x), {IN=>''}, {OUT=>''}, {EXIT=>1},
|
// ['empty-cc', qw('[::]' x), {IN=>''}, {OUT=>''}, {EXIT=>1},
|
||||||
|
|
|
@ -308,13 +308,13 @@ fn test_truncate_bytes_size() {
|
||||||
.args(&["--size", "1024R", "file"])
|
.args(&["--size", "1024R", "file"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("truncate: Invalid number: '1024R'");
|
.stderr_only("truncate: Invalid number: '1024R'\n");
|
||||||
#[cfg(not(target_pointer_width = "128"))]
|
#[cfg(not(target_pointer_width = "128"))]
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.args(&["--size", "1Y", "file"])
|
.args(&["--size", "1Y", "file"])
|
||||||
.fails()
|
.fails()
|
||||||
.code_is(1)
|
.code_is(1)
|
||||||
.stderr_only("truncate: Invalid number: '1Y': Value too large for defined data type");
|
.stderr_only("truncate: Invalid number: '1Y': Value too large for defined data type\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Test that truncating a non-existent file creates that file.
|
/// Test that truncating a non-existent file creates that file.
|
||||||
|
|
|
@ -28,8 +28,11 @@ fn test_uname_processor() {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_uname_hardware_platform() {
|
fn test_uname_hardware_platform() {
|
||||||
let result = new_ucmd!().arg("-i").succeeds();
|
new_ucmd!()
|
||||||
assert_eq!(result.stdout_str().trim_end(), "unknown");
|
.arg("-i")
|
||||||
|
.succeeds()
|
||||||
|
.stdout_str_apply(str::trim_end)
|
||||||
|
.stdout_only("unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
|
@ -168,7 +168,7 @@ fn test_invalid_utf8() {
|
||||||
.run()
|
.run()
|
||||||
.failure()
|
.failure()
|
||||||
.stderr_only(
|
.stderr_only(
|
||||||
"uniq: failed to convert line to utf8: invalid utf-8 sequence of 1 bytes from index 0",
|
"uniq: failed to convert line to utf8: invalid utf-8 sequence of 1 bytes from index 0\n",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// * For the full copyright and license information, please view the LICENSE
|
// * For the full copyright and license information, please view the LICENSE
|
||||||
// * file that was distributed with this source code.
|
// * file that was distributed with this source code.
|
||||||
|
|
||||||
//spell-checker: ignore (linux) rlimit prlimit coreutil ggroups uchild uncaptured
|
//spell-checker: ignore (linux) rlimit prlimit coreutil ggroups uchild uncaptured scmd
|
||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
|
@ -20,12 +20,14 @@ use std::fs::{self, hard_link, remove_file, File, OpenOptions};
|
||||||
use std::io::{self, BufWriter, Read, Result, Write};
|
use std::io::{self, BufWriter, Read, Result, Write};
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
use std::os::unix::fs::{symlink as symlink_dir, symlink as symlink_file, PermissionsExt};
|
use std::os::unix::fs::{symlink as symlink_dir, symlink as symlink_file, PermissionsExt};
|
||||||
|
#[cfg(unix)]
|
||||||
|
use std::os::unix::process::ExitStatusExt;
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use std::os::windows::fs::{symlink_dir, symlink_file};
|
use std::os::windows::fs::{symlink_dir, symlink_file};
|
||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
use std::path::MAIN_SEPARATOR;
|
use std::path::MAIN_SEPARATOR;
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
use std::process::{Child, Command, Output, Stdio};
|
use std::process::{Child, Command, ExitStatus, Output, Stdio};
|
||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use std::sync::mpsc::{self, RecvTimeoutError};
|
use std::sync::mpsc::{self, RecvTimeoutError};
|
||||||
use std::thread::{sleep, JoinHandle};
|
use std::thread::{sleep, JoinHandle};
|
||||||
|
@ -73,10 +75,7 @@ pub struct CmdResult {
|
||||||
//tmpd is used for convenience functions for asserts against fixtures
|
//tmpd is used for convenience functions for asserts against fixtures
|
||||||
tmpd: Option<Rc<TempDir>>,
|
tmpd: Option<Rc<TempDir>>,
|
||||||
/// exit status for command (if there is one)
|
/// exit status for command (if there is one)
|
||||||
code: Option<i32>,
|
exit_status: Option<ExitStatus>,
|
||||||
/// zero-exit from running the Command?
|
|
||||||
/// see [`success`]
|
|
||||||
success: bool,
|
|
||||||
/// captured standard output after running the Command
|
/// captured standard output after running the Command
|
||||||
stdout: Vec<u8>,
|
stdout: Vec<u8>,
|
||||||
/// captured standard error after running the Command
|
/// captured standard error after running the Command
|
||||||
|
@ -84,26 +83,233 @@ pub struct CmdResult {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CmdResult {
|
impl CmdResult {
|
||||||
pub fn new(
|
pub fn new<T, U>(
|
||||||
bin_path: String,
|
bin_path: String,
|
||||||
util_name: Option<String>,
|
util_name: Option<String>,
|
||||||
tmpd: Option<Rc<TempDir>>,
|
tmpd: Option<Rc<TempDir>>,
|
||||||
code: Option<i32>,
|
exit_status: Option<ExitStatus>,
|
||||||
success: bool,
|
stdout: T,
|
||||||
stdout: &[u8],
|
stderr: U,
|
||||||
stderr: &[u8],
|
) -> Self
|
||||||
) -> Self {
|
where
|
||||||
|
T: Into<Vec<u8>>,
|
||||||
|
U: Into<Vec<u8>>,
|
||||||
|
{
|
||||||
Self {
|
Self {
|
||||||
bin_path,
|
bin_path,
|
||||||
util_name,
|
util_name,
|
||||||
tmpd,
|
tmpd,
|
||||||
code,
|
exit_status,
|
||||||
success,
|
stdout: stdout.into(),
|
||||||
stdout: stdout.to_vec(),
|
stderr: stderr.into(),
|
||||||
stderr: stderr.to_vec(),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Apply a function to `stdout` as bytes and return a new [`CmdResult`]
|
||||||
|
pub fn stdout_apply<'a, F, R>(&'a self, function: F) -> Self
|
||||||
|
where
|
||||||
|
F: Fn(&'a [u8]) -> R,
|
||||||
|
R: Into<Vec<u8>>,
|
||||||
|
{
|
||||||
|
Self::new(
|
||||||
|
self.bin_path.clone(),
|
||||||
|
self.util_name.clone(),
|
||||||
|
self.tmpd.clone(),
|
||||||
|
self.exit_status,
|
||||||
|
function(&self.stdout),
|
||||||
|
self.stderr.as_slice(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Apply a function to `stdout` as `&str` and return a new [`CmdResult`]
|
||||||
|
pub fn stdout_str_apply<'a, F, R>(&'a self, function: F) -> Self
|
||||||
|
where
|
||||||
|
F: Fn(&'a str) -> R,
|
||||||
|
R: Into<Vec<u8>>,
|
||||||
|
{
|
||||||
|
Self::new(
|
||||||
|
self.bin_path.clone(),
|
||||||
|
self.util_name.clone(),
|
||||||
|
self.tmpd.clone(),
|
||||||
|
self.exit_status,
|
||||||
|
function(self.stdout_str()),
|
||||||
|
self.stderr.as_slice(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Apply a function to `stderr` as bytes and return a new [`CmdResult`]
|
||||||
|
pub fn stderr_apply<'a, F, R>(&'a self, function: F) -> Self
|
||||||
|
where
|
||||||
|
F: Fn(&'a [u8]) -> R,
|
||||||
|
R: Into<Vec<u8>>,
|
||||||
|
{
|
||||||
|
Self::new(
|
||||||
|
self.bin_path.clone(),
|
||||||
|
self.util_name.clone(),
|
||||||
|
self.tmpd.clone(),
|
||||||
|
self.exit_status,
|
||||||
|
self.stdout.as_slice(),
|
||||||
|
function(&self.stderr),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Apply a function to `stderr` as `&str` and return a new [`CmdResult`]
|
||||||
|
pub fn stderr_str_apply<'a, F, R>(&'a self, function: F) -> Self
|
||||||
|
where
|
||||||
|
F: Fn(&'a str) -> R,
|
||||||
|
R: Into<Vec<u8>>,
|
||||||
|
{
|
||||||
|
Self::new(
|
||||||
|
self.bin_path.clone(),
|
||||||
|
self.util_name.clone(),
|
||||||
|
self.tmpd.clone(),
|
||||||
|
self.exit_status,
|
||||||
|
self.stdout.as_slice(),
|
||||||
|
function(self.stderr_str()),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Assert `stdout` as bytes with a predicate function returning a `bool`.
|
||||||
|
#[track_caller]
|
||||||
|
pub fn stdout_check<'a, F>(&'a self, predicate: F) -> &Self
|
||||||
|
where
|
||||||
|
F: Fn(&'a [u8]) -> bool,
|
||||||
|
{
|
||||||
|
assert!(
|
||||||
|
predicate(&self.stdout),
|
||||||
|
"Predicate for stdout as `bytes` evaluated to false.\nstdout='{:?}'\nstderr='{:?}'\n",
|
||||||
|
&self.stdout,
|
||||||
|
&self.stderr
|
||||||
|
);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Assert `stdout` as `&str` with a predicate function returning a `bool`.
|
||||||
|
#[track_caller]
|
||||||
|
pub fn stdout_str_check<'a, F>(&'a self, predicate: F) -> &Self
|
||||||
|
where
|
||||||
|
F: Fn(&'a str) -> bool,
|
||||||
|
{
|
||||||
|
assert!(
|
||||||
|
predicate(self.stdout_str()),
|
||||||
|
"Predicate for stdout as `str` evaluated to false.\nstdout='{}'\nstderr='{}'\n",
|
||||||
|
self.stdout_str(),
|
||||||
|
self.stderr_str()
|
||||||
|
);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Assert `stderr` as bytes with a predicate function returning a `bool`.
|
||||||
|
#[track_caller]
|
||||||
|
pub fn stderr_check<'a, F>(&'a self, predicate: F) -> &Self
|
||||||
|
where
|
||||||
|
F: Fn(&'a [u8]) -> bool,
|
||||||
|
{
|
||||||
|
assert!(
|
||||||
|
predicate(&self.stderr),
|
||||||
|
"Predicate for stderr as `bytes` evaluated to false.\nstdout='{:?}'\nstderr='{:?}'\n",
|
||||||
|
&self.stdout,
|
||||||
|
&self.stderr
|
||||||
|
);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Assert `stderr` as `&str` with a predicate function returning a `bool`.
|
||||||
|
#[track_caller]
|
||||||
|
pub fn stderr_str_check<'a, F>(&'a self, predicate: F) -> &Self
|
||||||
|
where
|
||||||
|
F: Fn(&'a str) -> bool,
|
||||||
|
{
|
||||||
|
assert!(
|
||||||
|
predicate(self.stderr_str()),
|
||||||
|
"Predicate for stderr as `str` evaluated to false.\nstdout='{}'\nstderr='{}'\n",
|
||||||
|
self.stdout_str(),
|
||||||
|
self.stderr_str()
|
||||||
|
);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the exit status of the child process, if any.
|
||||||
|
///
|
||||||
|
/// Returns None if the child process is still running or hasn't been started.
|
||||||
|
pub fn try_exit_status(&self) -> Option<ExitStatus> {
|
||||||
|
self.exit_status
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the exit status of the child process.
|
||||||
|
///
|
||||||
|
/// # Panics
|
||||||
|
///
|
||||||
|
/// If the child process is still running or hasn't been started.
|
||||||
|
pub fn exit_status(&self) -> ExitStatus {
|
||||||
|
self.try_exit_status()
|
||||||
|
.expect("Program must be run first or has not finished, yet")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return the signal the child process received if any.
|
||||||
|
///
|
||||||
|
/// # Platform specific behavior
|
||||||
|
///
|
||||||
|
/// This method is only available on unix systems.
|
||||||
|
#[cfg(unix)]
|
||||||
|
pub fn signal(&self) -> Option<i32> {
|
||||||
|
self.exit_status().signal()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Assert that the given signal `value` equals the signal the child process received.
|
||||||
|
///
|
||||||
|
/// See also [`std::os::unix::process::ExitStatusExt::signal`].
|
||||||
|
///
|
||||||
|
/// # Platform specific behavior
|
||||||
|
///
|
||||||
|
/// This assertion method is only available on unix systems.
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[track_caller]
|
||||||
|
pub fn signal_is(&self, value: i32) -> &Self {
|
||||||
|
let actual = self.signal().unwrap_or_else(|| {
|
||||||
|
panic!(
|
||||||
|
"Expected process to be terminated by the '{}' signal, but exit status is: '{}'",
|
||||||
|
value,
|
||||||
|
self.try_exit_status()
|
||||||
|
.map_or("Not available".to_string(), |e| e.to_string())
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
assert_eq!(actual, value);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Assert that the given signal `name` equals the signal the child process received.
|
||||||
|
///
|
||||||
|
/// Strings like `SIGINT`, `INT` or a number like `15` are all valid names. See also
|
||||||
|
/// [`std::os::unix::process::ExitStatusExt::signal`] and
|
||||||
|
/// [`uucore::signals::signal_by_name_or_value`]
|
||||||
|
///
|
||||||
|
/// # Platform specific behavior
|
||||||
|
///
|
||||||
|
/// This assertion method is only available on unix systems.
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[track_caller]
|
||||||
|
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))
|
||||||
|
.try_into()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let actual = self.signal().unwrap_or_else(|| {
|
||||||
|
panic!(
|
||||||
|
"Expected process to be terminated by the '{}' signal, but exit status is: '{}'",
|
||||||
|
name,
|
||||||
|
self.try_exit_status()
|
||||||
|
.map_or("Not available".to_string(), |e| e.to_string())
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
assert_eq!(actual, expected);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns a reference to the program's standard output as a slice of bytes
|
/// Returns a reference to the program's standard output as a slice of bytes
|
||||||
pub fn stdout(&self) -> &[u8] {
|
pub fn stdout(&self) -> &[u8] {
|
||||||
&self.stdout
|
&self.stdout
|
||||||
|
@ -151,8 +357,7 @@ impl CmdResult {
|
||||||
/// Returns the program's exit code
|
/// Returns the program's exit code
|
||||||
/// Panics if not run or has not finished yet for example when run with `run_no_wait()`
|
/// Panics if not run or has not finished yet for example when run with `run_no_wait()`
|
||||||
pub fn code(&self) -> i32 {
|
pub fn code(&self) -> i32 {
|
||||||
self.code
|
self.exit_status().code().unwrap()
|
||||||
.expect("Program must be run first or has not finished, yet")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
|
@ -172,14 +377,14 @@ impl CmdResult {
|
||||||
|
|
||||||
/// Returns whether the program succeeded
|
/// Returns whether the program succeeded
|
||||||
pub fn succeeded(&self) -> bool {
|
pub fn succeeded(&self) -> bool {
|
||||||
self.success
|
self.exit_status.map_or(true, |e| e.success())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// asserts that the command resulted in a success (zero) status code
|
/// asserts that the command resulted in a success (zero) status code
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn success(&self) -> &Self {
|
pub fn success(&self) -> &Self {
|
||||||
assert!(
|
assert!(
|
||||||
self.success,
|
self.succeeded(),
|
||||||
"Command was expected to succeed.\nstdout = {}\n stderr = {}",
|
"Command was expected to succeed.\nstdout = {}\n stderr = {}",
|
||||||
self.stdout_str(),
|
self.stdout_str(),
|
||||||
self.stderr_str()
|
self.stderr_str()
|
||||||
|
@ -191,7 +396,7 @@ impl CmdResult {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn failure(&self) -> &Self {
|
pub fn failure(&self) -> &Self {
|
||||||
assert!(
|
assert!(
|
||||||
!self.success,
|
!self.succeeded(),
|
||||||
"Command was expected to fail.\nstdout = {}\n stderr = {}",
|
"Command was expected to fail.\nstdout = {}\n stderr = {}",
|
||||||
self.stdout_str(),
|
self.stdout_str(),
|
||||||
self.stderr_str()
|
self.stderr_str()
|
||||||
|
@ -269,7 +474,11 @@ impl CmdResult {
|
||||||
/// whose bytes equal those of the passed in slice
|
/// whose bytes equal those of the passed in slice
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn stdout_is_bytes<T: AsRef<[u8]>>(&self, msg: T) -> &Self {
|
pub fn stdout_is_bytes<T: AsRef<[u8]>>(&self, msg: T) -> &Self {
|
||||||
assert_eq!(self.stdout, msg.as_ref());
|
assert_eq!(self.stdout, msg.as_ref(),
|
||||||
|
"stdout as bytes wasn't equal to expected bytes. Result as strings:\nstdout ='{:?}'\nexpected='{:?}'",
|
||||||
|
std::str::from_utf8(&self.stdout),
|
||||||
|
std::str::from_utf8(msg.as_ref()),
|
||||||
|
);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,15 +545,13 @@ impl CmdResult {
|
||||||
self.stdout_is_any(&possible_values.collect::<Vec<_>>());
|
self.stdout_is_any(&possible_values.collect::<Vec<_>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// asserts that the command resulted in stderr stream output that equals the
|
/// assert that the command resulted in stderr stream output that equals the
|
||||||
/// passed in value, when both are trimmed of trailing whitespace
|
/// passed in value.
|
||||||
|
///
|
||||||
/// `stderr_only` is a better choice unless stdout may or will be non-empty
|
/// `stderr_only` is a better choice unless stdout may or will be non-empty
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn stderr_is<T: AsRef<str>>(&self, msg: T) -> &Self {
|
pub fn stderr_is<T: AsRef<str>>(&self, msg: T) -> &Self {
|
||||||
assert_eq!(
|
assert_eq!(self.stderr_str(), msg.as_ref());
|
||||||
self.stderr_str().trim_end(),
|
|
||||||
String::from(msg.as_ref()).trim_end()
|
|
||||||
);
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,7 +559,13 @@ impl CmdResult {
|
||||||
/// whose bytes equal those of the passed in slice
|
/// whose bytes equal those of the passed in slice
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn stderr_is_bytes<T: AsRef<[u8]>>(&self, msg: T) -> &Self {
|
pub fn stderr_is_bytes<T: AsRef<[u8]>>(&self, msg: T) -> &Self {
|
||||||
assert_eq!(self.stderr, msg.as_ref());
|
assert_eq!(
|
||||||
|
&self.stderr,
|
||||||
|
msg.as_ref(),
|
||||||
|
"stderr as bytes wasn't equal to expected bytes. Result as strings:\nstderr ='{:?}'\nexpected='{:?}'",
|
||||||
|
std::str::from_utf8(&self.stderr),
|
||||||
|
std::str::from_utf8(msg.as_ref())
|
||||||
|
);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -408,7 +621,7 @@ impl CmdResult {
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn fails_silently(&self) -> &Self {
|
pub fn fails_silently(&self) -> &Self {
|
||||||
assert!(!self.success);
|
assert!(!self.succeeded());
|
||||||
assert!(self.stderr.is_empty());
|
assert!(self.stderr.is_empty());
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -424,7 +637,7 @@ impl CmdResult {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
pub fn usage_error<T: AsRef<str>>(&self, msg: T) -> &Self {
|
pub fn usage_error<T: AsRef<str>>(&self, msg: T) -> &Self {
|
||||||
self.stderr_only(format!(
|
self.stderr_only(format!(
|
||||||
"{0}: {2}\nTry '{1} {0} --help' for more information.",
|
"{0}: {2}\nTry '{1} {0} --help' for more information.\n",
|
||||||
self.util_name.as_ref().unwrap(), // This shouldn't be called using a normal command
|
self.util_name.as_ref().unwrap(), // This shouldn't be called using a normal command
|
||||||
self.bin_path,
|
self.bin_path,
|
||||||
msg.as_ref()
|
msg.as_ref()
|
||||||
|
@ -1379,12 +1592,10 @@ impl<'a> UChildAssertion<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn with_output(&mut self, mode: AssertionMode) -> CmdResult {
|
fn with_output(&mut self, mode: AssertionMode) -> CmdResult {
|
||||||
let (code, success) = match self.uchild.is_alive() {
|
let exit_status = if self.uchild.is_alive() {
|
||||||
true => (None, true),
|
None
|
||||||
false => {
|
} else {
|
||||||
let status = self.uchild.raw.wait().unwrap();
|
Some(self.uchild.raw.wait().unwrap())
|
||||||
(status.code(), status.success())
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
let (stdout, stderr) = match mode {
|
let (stdout, stderr) = match mode {
|
||||||
AssertionMode::All => (
|
AssertionMode::All => (
|
||||||
|
@ -1401,8 +1612,7 @@ impl<'a> UChildAssertion<'a> {
|
||||||
bin_path: self.uchild.bin_path.clone(),
|
bin_path: self.uchild.bin_path.clone(),
|
||||||
util_name: self.uchild.util_name.clone(),
|
util_name: self.uchild.util_name.clone(),
|
||||||
tmpd: self.uchild.tmpd.clone(),
|
tmpd: self.uchild.tmpd.clone(),
|
||||||
code,
|
exit_status,
|
||||||
success,
|
|
||||||
stdout,
|
stdout,
|
||||||
stderr,
|
stderr,
|
||||||
}
|
}
|
||||||
|
@ -1631,8 +1841,7 @@ impl UChild {
|
||||||
bin_path,
|
bin_path,
|
||||||
util_name,
|
util_name,
|
||||||
tmpd,
|
tmpd,
|
||||||
code: output.status.code(),
|
exit_status: Some(output.status),
|
||||||
success: output.status.success(),
|
|
||||||
stdout: output.stdout,
|
stdout: output.stdout,
|
||||||
stderr: output.stderr,
|
stderr: output.stderr,
|
||||||
})
|
})
|
||||||
|
@ -2165,8 +2374,7 @@ pub fn expected_result(ts: &TestScenario, args: &[&str]) -> std::result::Result<
|
||||||
ts.bin_path.as_os_str().to_str().unwrap().to_string(),
|
ts.bin_path.as_os_str().to_str().unwrap().to_string(),
|
||||||
Some(ts.util_name.clone()),
|
Some(ts.util_name.clone()),
|
||||||
Some(result.tmpd()),
|
Some(result.tmpd()),
|
||||||
Some(result.code()),
|
result.exit_status,
|
||||||
result.succeeded(),
|
|
||||||
stdout.as_bytes(),
|
stdout.as_bytes(),
|
||||||
stderr.as_bytes(),
|
stderr.as_bytes(),
|
||||||
))
|
))
|
||||||
|
@ -2242,151 +2450,160 @@ mod tests {
|
||||||
// spell-checker:ignore (tests) asdfsadfa
|
// spell-checker:ignore (tests) asdfsadfa
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[cfg(unix)]
|
||||||
|
pub fn run_cmd<T: AsRef<OsStr>>(cmd: T) -> CmdResult {
|
||||||
|
let mut ucmd = UCommand::new_from_tmp::<&str, String>(
|
||||||
|
"sh",
|
||||||
|
&None,
|
||||||
|
Rc::new(tempfile::tempdir().unwrap()),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
ucmd.arg("-c");
|
||||||
|
ucmd.arg(cmd);
|
||||||
|
ucmd.run()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(windows)]
|
||||||
|
pub fn run_cmd<T: AsRef<OsStr>>(cmd: T) -> CmdResult {
|
||||||
|
let mut ucmd = UCommand::new_from_tmp::<&str, String>(
|
||||||
|
"cmd",
|
||||||
|
&None,
|
||||||
|
Rc::new(tempfile::tempdir().unwrap()),
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
ucmd.arg("/C");
|
||||||
|
ucmd.arg(cmd);
|
||||||
|
ucmd.run()
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_code_is() {
|
fn test_command_result_when_no_output_with_exit_32() {
|
||||||
let res = CmdResult {
|
let result = run_cmd("exit 32");
|
||||||
bin_path: String::new(),
|
|
||||||
util_name: None,
|
if cfg!(windows) {
|
||||||
tmpd: None,
|
std::assert!(result.bin_path.ends_with("cmd"));
|
||||||
code: Some(32),
|
} else {
|
||||||
success: false,
|
std::assert!(result.bin_path.ends_with("sh"));
|
||||||
stdout: "".into(),
|
}
|
||||||
stderr: "".into(),
|
|
||||||
};
|
std::assert!(result.util_name.is_none());
|
||||||
res.code_is(32);
|
std::assert!(result.tmpd.is_some());
|
||||||
|
|
||||||
|
assert!(result.exit_status.is_some());
|
||||||
|
std::assert_eq!(result.code(), 32);
|
||||||
|
result.code_is(32);
|
||||||
|
assert!(!result.succeeded());
|
||||||
|
result.failure();
|
||||||
|
result.fails_silently();
|
||||||
|
assert!(result.stderr.is_empty());
|
||||||
|
assert!(result.stdout.is_empty());
|
||||||
|
result.no_output();
|
||||||
|
result.no_stderr();
|
||||||
|
result.no_stdout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn test_code_is_fail() {
|
fn test_command_result_when_exit_32_then_success_panic() {
|
||||||
let res = CmdResult {
|
run_cmd("exit 32").success();
|
||||||
bin_path: String::new(),
|
|
||||||
util_name: None,
|
|
||||||
tmpd: None,
|
|
||||||
code: Some(32),
|
|
||||||
success: false,
|
|
||||||
stdout: "".into(),
|
|
||||||
stderr: "".into(),
|
|
||||||
};
|
|
||||||
res.code_is(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_failure() {
|
fn test_command_result_when_no_output_with_exit_0() {
|
||||||
let res = CmdResult {
|
let result = run_cmd("exit 0");
|
||||||
bin_path: String::new(),
|
|
||||||
util_name: None,
|
assert!(result.exit_status.is_some());
|
||||||
tmpd: None,
|
std::assert_eq!(result.code(), 0);
|
||||||
code: None,
|
result.code_is(0);
|
||||||
success: false,
|
assert!(result.succeeded());
|
||||||
stdout: "".into(),
|
result.success();
|
||||||
stderr: "".into(),
|
assert!(result.stderr.is_empty());
|
||||||
};
|
assert!(result.stdout.is_empty());
|
||||||
res.failure();
|
result.no_output();
|
||||||
|
result.no_stderr();
|
||||||
|
result.no_stdout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn test_failure_fail() {
|
fn test_command_result_when_exit_0_then_failure_panics() {
|
||||||
let res = CmdResult {
|
run_cmd("exit 0").failure();
|
||||||
bin_path: String::new(),
|
|
||||||
util_name: None,
|
|
||||||
tmpd: None,
|
|
||||||
code: None,
|
|
||||||
success: true,
|
|
||||||
stdout: "".into(),
|
|
||||||
stderr: "".into(),
|
|
||||||
};
|
|
||||||
res.failure();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn test_success() {
|
|
||||||
let res = CmdResult {
|
|
||||||
bin_path: String::new(),
|
|
||||||
util_name: None,
|
|
||||||
tmpd: None,
|
|
||||||
code: None,
|
|
||||||
success: true,
|
|
||||||
stdout: "".into(),
|
|
||||||
stderr: "".into(),
|
|
||||||
};
|
|
||||||
res.success();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn test_success_fail() {
|
fn test_command_result_when_exit_0_then_silent_failure_panics() {
|
||||||
let res = CmdResult {
|
run_cmd("exit 0").fails_silently();
|
||||||
bin_path: String::new(),
|
|
||||||
util_name: None,
|
|
||||||
tmpd: None,
|
|
||||||
code: None,
|
|
||||||
success: false,
|
|
||||||
stdout: "".into(),
|
|
||||||
stderr: "".into(),
|
|
||||||
};
|
|
||||||
res.success();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_no_stderr_output() {
|
fn test_command_result_when_stdout_with_exit_0() {
|
||||||
let res = CmdResult {
|
#[cfg(windows)]
|
||||||
bin_path: String::new(),
|
let (result, vector, string) = (
|
||||||
util_name: None,
|
run_cmd("echo hello& exit 0"),
|
||||||
tmpd: None,
|
vec![b'h', b'e', b'l', b'l', b'o', b'\r', b'\n'],
|
||||||
code: None,
|
"hello\r\n",
|
||||||
success: true,
|
);
|
||||||
stdout: "".into(),
|
#[cfg(not(windows))]
|
||||||
stderr: "".into(),
|
let (result, vector, string) = (
|
||||||
};
|
run_cmd("echo hello; exit 0"),
|
||||||
res.no_stderr();
|
vec![b'h', b'e', b'l', b'l', b'o', b'\n'],
|
||||||
res.no_stdout();
|
"hello\n",
|
||||||
|
);
|
||||||
|
|
||||||
|
assert!(result.exit_status.is_some());
|
||||||
|
std::assert_eq!(result.code(), 0);
|
||||||
|
result.code_is(0);
|
||||||
|
assert!(result.succeeded());
|
||||||
|
result.success();
|
||||||
|
assert!(result.stderr.is_empty());
|
||||||
|
std::assert_eq!(result.stdout, vector);
|
||||||
|
result.no_stderr();
|
||||||
|
result.stdout_is(string);
|
||||||
|
result.stdout_is_bytes(&vector);
|
||||||
|
result.stdout_only(string);
|
||||||
|
result.stdout_only_bytes(&vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
fn test_command_result_when_stderr_with_exit_0() {
|
||||||
fn test_no_stderr_fail() {
|
#[cfg(windows)]
|
||||||
let res = CmdResult {
|
let (result, vector, string) = (
|
||||||
bin_path: String::new(),
|
run_cmd("echo hello>&2& exit 0"),
|
||||||
util_name: None,
|
vec![b'h', b'e', b'l', b'l', b'o', b'\r', b'\n'],
|
||||||
tmpd: None,
|
"hello\r\n",
|
||||||
code: None,
|
);
|
||||||
success: true,
|
#[cfg(not(windows))]
|
||||||
stdout: "".into(),
|
let (result, vector, string) = (
|
||||||
stderr: "asdfsadfa".into(),
|
run_cmd("echo hello >&2; exit 0"),
|
||||||
};
|
vec![b'h', b'e', b'l', b'l', b'o', b'\n'],
|
||||||
|
"hello\n",
|
||||||
|
);
|
||||||
|
|
||||||
res.no_stderr();
|
assert!(result.exit_status.is_some());
|
||||||
}
|
std::assert_eq!(result.code(), 0);
|
||||||
|
result.code_is(0);
|
||||||
#[test]
|
assert!(result.succeeded());
|
||||||
#[should_panic]
|
result.success();
|
||||||
fn test_no_stdout_fail() {
|
assert!(result.stdout.is_empty());
|
||||||
let res = CmdResult {
|
result.no_stdout();
|
||||||
bin_path: String::new(),
|
std::assert_eq!(result.stderr, vector);
|
||||||
util_name: None,
|
result.stderr_is(string);
|
||||||
tmpd: None,
|
result.stderr_is_bytes(&vector);
|
||||||
code: None,
|
result.stderr_only(string);
|
||||||
success: true,
|
result.stderr_only_bytes(&vector);
|
||||||
stdout: "asdfsadfa".into(),
|
|
||||||
stderr: "".into(),
|
|
||||||
};
|
|
||||||
|
|
||||||
res.no_stdout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_std_does_not_contain() {
|
fn test_std_does_not_contain() {
|
||||||
let res = CmdResult {
|
#[cfg(windows)]
|
||||||
bin_path: String::new(),
|
let res = run_cmd(
|
||||||
util_name: None,
|
"(echo This is a likely error message& echo This is a likely error message>&2) & exit 0",
|
||||||
tmpd: None,
|
);
|
||||||
code: None,
|
#[cfg(not(windows))]
|
||||||
success: true,
|
let res = run_cmd(
|
||||||
stdout: "This is a likely error message\n".into(),
|
"echo This is a likely error message; echo This is a likely error message >&2; exit 0",
|
||||||
stderr: "This is a likely error message\n".into(),
|
);
|
||||||
};
|
|
||||||
res.stdout_does_not_contain("unlikely");
|
res.stdout_does_not_contain("unlikely");
|
||||||
res.stderr_does_not_contain("unlikely");
|
res.stderr_does_not_contain("unlikely");
|
||||||
}
|
}
|
||||||
|
@ -2394,15 +2611,10 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn test_stdout_does_not_contain_fail() {
|
fn test_stdout_does_not_contain_fail() {
|
||||||
let res = CmdResult {
|
#[cfg(windows)]
|
||||||
bin_path: String::new(),
|
let res = run_cmd("echo This is a likely error message& exit 0");
|
||||||
util_name: None,
|
#[cfg(not(windows))]
|
||||||
tmpd: None,
|
let res = run_cmd("echo This is a likely error message; exit 0");
|
||||||
code: None,
|
|
||||||
success: true,
|
|
||||||
stdout: "This is a likely error message\n".into(),
|
|
||||||
stderr: "".into(),
|
|
||||||
};
|
|
||||||
|
|
||||||
res.stdout_does_not_contain("likely");
|
res.stdout_does_not_contain("likely");
|
||||||
}
|
}
|
||||||
|
@ -2410,30 +2622,25 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn test_stderr_does_not_contain_fail() {
|
fn test_stderr_does_not_contain_fail() {
|
||||||
let res = CmdResult {
|
#[cfg(windows)]
|
||||||
bin_path: String::new(),
|
let res = run_cmd("echo This is a likely error message>&2 & exit 0");
|
||||||
util_name: None,
|
#[cfg(not(windows))]
|
||||||
tmpd: None,
|
let res = run_cmd("echo This is a likely error message >&2; exit 0");
|
||||||
code: None,
|
|
||||||
success: true,
|
|
||||||
stdout: "".into(),
|
|
||||||
stderr: "This is a likely error message\n".into(),
|
|
||||||
};
|
|
||||||
|
|
||||||
res.stderr_does_not_contain("likely");
|
res.stderr_does_not_contain("likely");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_stdout_matches() {
|
fn test_stdout_matches() {
|
||||||
let res = CmdResult {
|
#[cfg(windows)]
|
||||||
bin_path: String::new(),
|
let res = run_cmd(
|
||||||
util_name: None,
|
"(echo This is a likely error message& echo This is a likely error message>&2 ) & exit 0",
|
||||||
tmpd: None,
|
);
|
||||||
code: None,
|
#[cfg(not(windows))]
|
||||||
success: true,
|
let res = run_cmd(
|
||||||
stdout: "This is a likely error message\n".into(),
|
"echo This is a likely error message; echo This is a likely error message >&2; exit 0",
|
||||||
stderr: "This is a likely error message\n".into(),
|
);
|
||||||
};
|
|
||||||
let positive = regex::Regex::new(".*likely.*").unwrap();
|
let positive = regex::Regex::new(".*likely.*").unwrap();
|
||||||
let negative = regex::Regex::new(".*unlikely.*").unwrap();
|
let negative = regex::Regex::new(".*unlikely.*").unwrap();
|
||||||
res.stdout_matches(&positive);
|
res.stdout_matches(&positive);
|
||||||
|
@ -2443,70 +2650,188 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn test_stdout_matches_fail() {
|
fn test_stdout_matches_fail() {
|
||||||
let res = CmdResult {
|
#[cfg(windows)]
|
||||||
bin_path: String::new(),
|
let res = run_cmd(
|
||||||
util_name: None,
|
"(echo This is a likely error message& echo This is a likely error message>&2) & exit 0",
|
||||||
tmpd: None,
|
);
|
||||||
code: None,
|
#[cfg(not(windows))]
|
||||||
success: true,
|
let res = run_cmd(
|
||||||
stdout: "This is a likely error message\n".into(),
|
"echo This is a likely error message; echo This is a likely error message >&2; exit 0",
|
||||||
stderr: "This is a likely error message\n".into(),
|
);
|
||||||
};
|
|
||||||
let negative = regex::Regex::new(".*unlikely.*").unwrap();
|
|
||||||
|
|
||||||
|
let negative = regex::Regex::new(".*unlikely.*").unwrap();
|
||||||
res.stdout_matches(&negative);
|
res.stdout_matches(&negative);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn test_stdout_not_matches_fail() {
|
fn test_stdout_not_matches_fail() {
|
||||||
let res = CmdResult {
|
#[cfg(windows)]
|
||||||
bin_path: String::new(),
|
let res = run_cmd(
|
||||||
util_name: None,
|
"(echo This is a likely error message& echo This is a likely error message>&2) & exit 0",
|
||||||
tmpd: None,
|
);
|
||||||
code: None,
|
#[cfg(not(windows))]
|
||||||
success: true,
|
let res = run_cmd(
|
||||||
stdout: "This is a likely error message\n".into(),
|
"echo This is a likely error message; echo This is a likely error message >&2; exit 0",
|
||||||
stderr: "This is a likely error message\n".into(),
|
);
|
||||||
};
|
|
||||||
let positive = regex::Regex::new(".*likely.*").unwrap();
|
|
||||||
|
|
||||||
|
let positive = regex::Regex::new(".*likely.*").unwrap();
|
||||||
res.stdout_does_not_match(&positive);
|
res.stdout_does_not_match(&positive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "echo")]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_normalized_newlines_stdout_is() {
|
fn test_normalized_newlines_stdout_is() {
|
||||||
let res = CmdResult {
|
let ts = TestScenario::new("echo");
|
||||||
bin_path: String::new(),
|
let res = ts.ucmd().args(&["-ne", "A\r\nB\nC"]).run();
|
||||||
util_name: None,
|
|
||||||
tmpd: None,
|
|
||||||
code: None,
|
|
||||||
success: true,
|
|
||||||
stdout: "A\r\nB\nC".into(),
|
|
||||||
stderr: "".into(),
|
|
||||||
};
|
|
||||||
|
|
||||||
res.normalized_newlines_stdout_is("A\r\nB\nC");
|
res.normalized_newlines_stdout_is("A\r\nB\nC");
|
||||||
res.normalized_newlines_stdout_is("A\nB\nC");
|
res.normalized_newlines_stdout_is("A\nB\nC");
|
||||||
res.normalized_newlines_stdout_is("A\nB\r\nC");
|
res.normalized_newlines_stdout_is("A\nB\r\nC");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "echo")]
|
||||||
#[test]
|
#[test]
|
||||||
#[should_panic]
|
#[should_panic]
|
||||||
fn test_normalized_newlines_stdout_is_fail() {
|
fn test_normalized_newlines_stdout_is_fail() {
|
||||||
let res = CmdResult {
|
let ts = TestScenario::new("echo");
|
||||||
bin_path: String::new(),
|
let res = ts.ucmd().args(&["-ne", "A\r\nB\nC"]).run();
|
||||||
util_name: None,
|
|
||||||
tmpd: None,
|
|
||||||
code: None,
|
|
||||||
success: true,
|
|
||||||
stdout: "A\r\nB\nC".into(),
|
|
||||||
stderr: "".into(),
|
|
||||||
};
|
|
||||||
|
|
||||||
res.normalized_newlines_stdout_is("A\r\nB\nC\n");
|
res.normalized_newlines_stdout_is("A\r\nB\nC\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "echo")]
|
||||||
|
#[test]
|
||||||
|
fn test_cmd_result_stdout_check_and_stdout_str_check() {
|
||||||
|
let result = TestScenario::new("echo").ucmd().arg("Hello world").run();
|
||||||
|
|
||||||
|
result.stdout_str_check(|stdout| stdout.ends_with("world\n"));
|
||||||
|
result.stdout_check(|stdout| stdout.get(0..2).unwrap().eq(&[b'H', b'e']));
|
||||||
|
result.no_stderr();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "echo")]
|
||||||
|
#[test]
|
||||||
|
fn test_cmd_result_stderr_check_and_stderr_str_check() {
|
||||||
|
let ts = TestScenario::new("echo");
|
||||||
|
let result = run_cmd(format!(
|
||||||
|
"{} {} Hello world >&2",
|
||||||
|
ts.bin_path.display(),
|
||||||
|
ts.util_name
|
||||||
|
));
|
||||||
|
|
||||||
|
result.stderr_str_check(|stderr| stderr.ends_with("world\n"));
|
||||||
|
result.stderr_check(|stderr| stderr.get(0..2).unwrap().eq(&[b'H', b'e']));
|
||||||
|
result.no_stdout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "echo")]
|
||||||
|
#[test]
|
||||||
|
#[should_panic]
|
||||||
|
fn test_cmd_result_stdout_str_check_when_false_then_panics() {
|
||||||
|
let result = TestScenario::new("echo").ucmd().arg("Hello world").run();
|
||||||
|
result.stdout_str_check(str::is_empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "echo")]
|
||||||
|
#[test]
|
||||||
|
#[should_panic]
|
||||||
|
fn test_cmd_result_stdout_check_when_false_then_panics() {
|
||||||
|
let result = TestScenario::new("echo").ucmd().arg("Hello world").run();
|
||||||
|
result.stdout_check(|s| s.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "echo")]
|
||||||
|
#[test]
|
||||||
|
#[should_panic]
|
||||||
|
fn test_cmd_result_stderr_str_check_when_false_then_panics() {
|
||||||
|
let result = TestScenario::new("echo").ucmd().arg("Hello world").run();
|
||||||
|
result.stderr_str_check(|s| !s.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "echo")]
|
||||||
|
#[test]
|
||||||
|
#[should_panic]
|
||||||
|
fn test_cmd_result_stderr_check_when_false_then_panics() {
|
||||||
|
let result = TestScenario::new("echo").ucmd().arg("Hello world").run();
|
||||||
|
result.stderr_check(|s| !s.is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "echo")]
|
||||||
|
#[test]
|
||||||
|
#[should_panic]
|
||||||
|
fn test_cmd_result_stdout_check_when_predicate_panics_then_panic() {
|
||||||
|
let result = TestScenario::new("echo").ucmd().run();
|
||||||
|
result.stdout_str_check(|_| panic!("Just testing"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "echo")]
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_cmd_result_signal_when_normal_exit_then_no_signal() {
|
||||||
|
let result = TestScenario::new("echo").ucmd().run();
|
||||||
|
assert!(result.signal().is_none());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "sleep")]
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
#[should_panic = "Program must be run first or has not finished"]
|
||||||
|
fn test_cmd_result_signal_when_still_running_then_panic() {
|
||||||
|
let mut child = TestScenario::new("sleep").ucmd().arg("60").run_no_wait();
|
||||||
|
|
||||||
|
child
|
||||||
|
.make_assertion()
|
||||||
|
.is_alive()
|
||||||
|
.with_current_output()
|
||||||
|
.signal();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "sleep")]
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[test]
|
||||||
|
fn test_cmd_result_signal_when_kill_then_signal() {
|
||||||
|
let mut child = TestScenario::new("sleep").ucmd().arg("60").run_no_wait();
|
||||||
|
|
||||||
|
child.kill();
|
||||||
|
child
|
||||||
|
.make_assertion()
|
||||||
|
.is_not_alive()
|
||||||
|
.with_current_output()
|
||||||
|
.signal_is(9)
|
||||||
|
.signal_name_is("SIGKILL")
|
||||||
|
.signal_name_is("KILL")
|
||||||
|
.signal_name_is("9")
|
||||||
|
.signal()
|
||||||
|
.expect("Signal was none");
|
||||||
|
|
||||||
|
let result = child.wait().unwrap();
|
||||||
|
result
|
||||||
|
.signal_is(9)
|
||||||
|
.signal_name_is("SIGKILL")
|
||||||
|
.signal_name_is("KILL")
|
||||||
|
.signal_name_is("9")
|
||||||
|
.signal()
|
||||||
|
.expect("Signal was none");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "sleep")]
|
||||||
|
#[cfg(unix)]
|
||||||
|
#[rstest]
|
||||||
|
#[case::signal_full_name_lower_case("sigkill")]
|
||||||
|
#[case::signal_short_name_lower_case("kill")]
|
||||||
|
#[case::signal_only_part_of_name("IGKILL")] // spell-checker: disable-line
|
||||||
|
#[case::signal_just_sig("SIG")]
|
||||||
|
#[case::signal_value_too_high("100")]
|
||||||
|
#[case::signal_value_negative("-1")]
|
||||||
|
#[should_panic = "Invalid signal name or value"]
|
||||||
|
fn test_cmd_result_signal_when_invalid_signal_name_then_panic(#[case] signal_name: &str) {
|
||||||
|
let mut child = TestScenario::new("sleep").ucmd().arg("60").run_no_wait();
|
||||||
|
child.kill();
|
||||||
|
let result = child.wait().unwrap();
|
||||||
|
result.signal_name_is(signal_name);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
fn test_parse_coreutil_version() {
|
fn test_parse_coreutil_version() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue