1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-15 19:36:16 +00:00

Merge branch 'main' into rm-correct-prompts

This commit is contained in:
Pat Laster 2022-10-24 18:36:52 -05:00 committed by GitHub
commit 9069d4832a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 123 additions and 8 deletions

View file

@ -217,15 +217,18 @@ fn test_cp_target_directory_is_file() {
#[test]
fn test_cp_arg_interactive() {
new_ucmd!()
.arg(TEST_HELLO_WORLD_SOURCE)
.arg(TEST_HOW_ARE_YOU_SOURCE)
.arg("-i")
let (at, mut ucmd) = at_and_ucmd!();
at.touch("a");
at.touch("b");
// TODO The prompt in GNU cp is different, and it doesn't have the
// response either.
//
// See <https://github.com/uutils/coreutils/issues/4023>.
ucmd.args(&["-i", "a", "b"])
.pipe_in("N\n")
.succeeds()
.no_stdout()
.stderr_contains(format!("overwrite '{}'?", TEST_HOW_ARE_YOU_SOURCE))
.stderr_contains("Not overwriting");
.stderr_is("cp: overwrite 'b'? [y/N]: cp: Not overwriting 'b' at user request\n");
}
#[test]
@ -1996,6 +1999,19 @@ fn test_copy_same_symlink_no_dereference_dangling() {
ucmd.args(&["-d", "a", "b"]).succeeds();
}
#[cfg(not(windows))]
#[test]
fn test_cp_parents_2_dirs() {
let (at, mut ucmd) = at_and_ucmd!();
at.mkdir_all("a/b/c");
at.mkdir("d");
ucmd.args(&["-a", "--parents", "a/b/c", "d"])
.succeeds()
.no_stderr()
.no_stdout();
assert!(at.dir_exists("d/a/b/c"));
}
#[test]
#[ignore = "issue #3332"]
fn test_cp_parents_2() {

View file

@ -184,6 +184,11 @@ fn test_negative() {
.stdout_is("-1.0Ki\n-1.2Mi\n-103Mi\n");
}
#[test]
fn test_negative_zero() {
new_ucmd!().pipe_in("-0\n-0.0").run().stdout_is("0\n0.0\n");
}
#[test]
fn test_no_op() {
new_ucmd!()

View file

@ -743,3 +743,19 @@ fn test_hex_suffix() {
assert_eq!(at.read("x0b"), "c");
assert_eq!(at.read("x0c"), "");
}
#[test]
fn test_round_robin() {
let (at, mut ucmd) = at_and_ucmd!();
let file_read = |f| {
let mut s = String::new();
at.open(f).read_to_string(&mut s).unwrap();
s
};
ucmd.args(&["-n", "r/2", "fivelines.txt"]).succeeds();
assert_eq!(file_read("xaa"), "1\n3\n5\n");
assert_eq!(file_read("xab"), "2\n4\n");
}