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

Merge pull request #7061 from DaringCuteSeal/cp-stream-2

cp: implement copying from streams
This commit is contained in:
Sylvestre Ledru 2025-01-13 14:13:13 +01:00 committed by GitHub
commit 74d80eab0a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 189 additions and 50 deletions

View file

@ -3471,15 +3471,9 @@ fn test_same_file_force_backup() {
}
/// Test for copying the contents of a FIFO as opposed to the FIFO object itself.
#[cfg(all(unix, not(target_os = "freebsd"), not(target_os = "openbsd")))]
#[cfg(unix)]
#[test]
fn test_copy_contents_fifo() {
// TODO this test should work on FreeBSD, but the command was
// causing an error:
//
// cp: 'fifo' -> 'outfile': the source path is neither a regular file nor a symlink to a regular file
//
// the underlying `std::fs:copy` doesn't support copying fifo on freeBSD
let scenario = TestScenario::new(util_name!());
let at = &scenario.fixtures;
@ -6037,3 +6031,19 @@ fn test_cp_preserve_xattr_readonly_source() {
"Extended attributes were not preserved"
);
}
#[test]
#[cfg(unix)]
fn test_cp_from_stdin() {
let (at, mut ucmd) = at_and_ucmd!();
let target = "target";
let test_string = "Hello, World!\n";
ucmd.arg("/dev/fd/0")
.arg(target)
.pipe_in(test_string)
.succeeds();
assert!(at.file_exists(target));
assert_eq!(at.read(target), test_string);
}