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

test_stat: expand scope for stdin tests

On Android and macOS all/some tests for stdin fail with:
`cannot stat '-': No such file or directory`
Apparently the `/dev/stdin` redirect workaround doesn't work for
these targets.
This commit is contained in:
Jan Scheer 2022-05-12 19:22:50 +02:00
parent 1de10b8333
commit fa94591b72
No known key found for this signature in database
GPG key ID: C62AD4C29E2B9828

View file

@ -360,12 +360,11 @@ fn test_pipe_fifo() {
} }
#[test] #[test]
#[cfg(target_os = "linux")] #[cfg(all(unix, not(target_os = "android")))]
fn test_stdin_pipe_fifo1() { fn test_stdin_pipe_fifo1() {
// $ echo | stat - // $ echo | stat -
// File: - // File: -
// Size: 0 Blocks: 0 IO Block: 4096 fifo // Size: 0 Blocks: 0 IO Block: 4096 fifo
// use std::process::{Command, Stdio};
new_ucmd!() new_ucmd!()
.arg("-") .arg("-")
.set_stdin(std::process::Stdio::piped()) .set_stdin(std::process::Stdio::piped())
@ -374,7 +373,6 @@ fn test_stdin_pipe_fifo1() {
.stdout_contains("fifo") .stdout_contains("fifo")
.stdout_contains("File: -") .stdout_contains("File: -")
.succeeded(); .succeeded();
new_ucmd!() new_ucmd!()
.args(&["-L", "-"]) .args(&["-L", "-"])
.set_stdin(std::process::Stdio::piped()) .set_stdin(std::process::Stdio::piped())
@ -386,7 +384,7 @@ fn test_stdin_pipe_fifo1() {
} }
#[test] #[test]
#[cfg(target_os = "linux")] #[cfg(all(unix, not(target_os = "android")))]
fn test_stdin_pipe_fifo2() { fn test_stdin_pipe_fifo2() {
// $ stat - // $ stat -
// File: - // File: -
@ -402,16 +400,15 @@ fn test_stdin_pipe_fifo2() {
} }
#[test] #[test]
#[cfg(target_os = "linux")] #[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))]
fn test_stdin_redirect() { fn test_stdin_redirect() {
// $ touch f && stat - < f // $ touch f && stat - < f
// File: - // File: -
// Size: 0 Blocks: 0 IO Block: 4096 regular empty file // Size: 0 Blocks: 0 IO Block: 4096 regular empty file
let ts = TestScenario::new(util_name!()); let ts = TestScenario::new(util_name!());
let at = &ts.fixtures; let at = &ts.fixtures;
at.touch("f"); at.touch("f");
new_ucmd!() ts.ucmd()
.arg("-") .arg("-")
.set_stdin(std::fs::File::open(at.plus("f")).unwrap()) .set_stdin(std::fs::File::open(at.plus("f")).unwrap())
.run() .run()