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

Merge branch 'main' into cp-symbolic-link-loop

This commit is contained in:
jfinkels 2022-10-09 17:28:30 -04:00 committed by GitHub
commit 349320ae61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 1631 additions and 1183 deletions

View file

@ -2681,6 +2681,73 @@ fn test_ls_ignore_backups() {
.stdout_does_not_contain(".somehiddenbackup~");
}
// This test fails on windows, see details at #3985
#[cfg(not(windows))]
#[test]
fn test_ls_ignore_explicit_period() {
// In ls ignore patterns, leading periods must be explicitly specified
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.touch(".hidden.yml");
at.touch("regular.yml");
scene
.ucmd()
.arg("-a")
.arg("--ignore")
.arg("?hidden.yml")
.succeeds()
.stdout_contains(".hidden.yml")
.stdout_contains("regular.yml");
scene
.ucmd()
.arg("-a")
.arg("--ignore")
.arg("*.yml")
.succeeds()
.stdout_contains(".hidden.yml")
.stdout_does_not_contain("regular.yml");
// Leading period is explicitly specified
scene
.ucmd()
.arg("-a")
.arg("--ignore")
.arg(".*.yml")
.succeeds()
.stdout_does_not_contain(".hidden.yml")
.stdout_contains("regular.yml");
}
// This test fails on windows, see details at #3985
#[cfg(not(windows))]
#[test]
fn test_ls_ignore_negation() {
let scene = TestScenario::new(util_name!());
let at = &scene.fixtures;
at.touch("apple");
at.touch("boy");
scene
.ucmd()
.arg("--ignore")
.arg("[!a]*")
.succeeds()
.stdout_contains("apple")
.stdout_does_not_contain("boy");
scene
.ucmd()
.arg("--ignore")
.arg("[^a]*")
.succeeds()
.stdout_contains("apple")
.stdout_does_not_contain("boy");
}
#[test]
fn test_ls_directory() {
let scene = TestScenario::new(util_name!());

View file

@ -701,3 +701,29 @@ fn test_multiple_of_input_chunk() {
}
assert_eq!(glob.collate(), at.read_bytes(name));
}
#[test]
fn test_numeric_suffix() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["-n", "4", "--numeric-suffixes", "9", "threebytes.txt"])
.succeeds()
.no_stdout()
.no_stderr();
assert_eq!(at.read("x09"), "a");
assert_eq!(at.read("x10"), "b");
assert_eq!(at.read("x11"), "c");
assert_eq!(at.read("x12"), "");
}
#[test]
fn test_hex_suffix() {
let (at, mut ucmd) = at_and_ucmd!();
ucmd.args(&["-n", "4", "--hex-suffixes", "9", "threebytes.txt"])
.succeeds()
.no_stdout()
.no_stderr();
assert_eq!(at.read("x09"), "a");
assert_eq!(at.read("x0a"), "b");
assert_eq!(at.read("x0b"), "c");
assert_eq!(at.read("x0c"), "");
}

View file

@ -44,3 +44,40 @@ fn test_sync_no_existing_files() {
.fails()
.stderr_contains("cannot stat");
}
#[test]
fn test_sync_data_but_not_file() {
new_ucmd!()
.arg("--data")
.fails()
.stderr_contains("sync: --data needs at least one argument");
}
#[cfg(any(target_os = "linux", target_os = "android"))]
#[cfg(feature = "chmod")]
#[test]
fn test_sync_no_permission_dir() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
let dir = "foo";
at.mkdir_all(dir);
ts.ccmd("chmod").arg("0").arg(dir).succeeds();
let result = ts.ucmd().arg("--data").arg(dir).fails();
result.stderr_contains("sync: error opening 'foo': Permission denied");
let result = ts.ucmd().arg(dir).fails();
result.stderr_contains("sync: error opening 'foo': Permission denied");
}
#[cfg(not(target_os = "windows"))]
#[cfg(feature = "chmod")]
#[test]
fn test_sync_no_permission_file() {
let ts = TestScenario::new(util_name!());
let at = &ts.fixtures;
let f = "file";
at.touch(f);
ts.ccmd("chmod").arg("0200").arg(f).succeeds();
ts.ucmd().arg(f).succeeds();
}

File diff suppressed because it is too large Load diff

View file

@ -311,4 +311,30 @@ mod tests {
);
assert!(random_string.as_bytes().ends_with(&[0]));
}
/// Originally used to exclude an error within the `random` module. The two
/// affected tests timed out on windows, but only in the ci. These tests are
/// also the source for the concrete numbers. The timed out tests are
/// `test_tail.rs::test_pipe_when_lines_option_given_input_size_has_multiple_size_of_buffer_size`
/// `test_tail.rs::test_pipe_when_bytes_option_given_input_size_has_multiple_size_of_buffer_size`.
#[test]
fn test_generate_random_strings_when_length_is_around_critical_buffer_sizes() {
let length = 8192 * 3;
let random_string = RandomString::generate(AlphanumericNewline, length);
assert_eq!(length, random_string.len());
let length = 8192 * 3 + 1;
let random_string =
RandomString::generate_with_delimiter(&Alphanumeric, b'\n', 100, true, length);
assert_eq!(length, random_string.len());
assert_eq!(
100,
random_string
.as_bytes()
.iter()
.filter(|p| **p == b'\n')
.count()
);
assert!(!random_string.as_bytes().ends_with(&[0]));
}
}