From 3b9a0c32a0b87236c9397590ac93e3c8add5bcb4 Mon Sep 17 00:00:00 2001 From: Daringcuteseal Date: Fri, 3 Jan 2025 19:09:03 +0700 Subject: [PATCH] tests/cp: add test to copy from stdin --- tests/by-util/test_cp.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/by-util/test_cp.rs b/tests/by-util/test_cp.rs index 5c9e8d5af5e..ddcc5e79af9 100644 --- a/tests/by-util/test_cp.rs +++ b/tests/by-util/test_cp.rs @@ -5914,3 +5914,19 @@ fn test_cp_no_file() { .code_is(1) .stderr_contains("error: the following required arguments were not provided:"); } + +#[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); +}