From fa94591b723b52a6b6435c876e1b42c61ed24929 Mon Sep 17 00:00:00 2001 From: Jan Scheer Date: Thu, 12 May 2022 19:22:50 +0200 Subject: [PATCH] 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. --- tests/by-util/test_stat.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/by-util/test_stat.rs b/tests/by-util/test_stat.rs index 14aba96fc..681850467 100644 --- a/tests/by-util/test_stat.rs +++ b/tests/by-util/test_stat.rs @@ -360,12 +360,11 @@ fn test_pipe_fifo() { } #[test] -#[cfg(target_os = "linux")] +#[cfg(all(unix, not(target_os = "android")))] fn test_stdin_pipe_fifo1() { // $ echo | stat - // File: - // Size: 0 Blocks: 0 IO Block: 4096 fifo - // use std::process::{Command, Stdio}; new_ucmd!() .arg("-") .set_stdin(std::process::Stdio::piped()) @@ -374,7 +373,6 @@ fn test_stdin_pipe_fifo1() { .stdout_contains("fifo") .stdout_contains("File: -") .succeeded(); - new_ucmd!() .args(&["-L", "-"]) .set_stdin(std::process::Stdio::piped()) @@ -386,7 +384,7 @@ fn test_stdin_pipe_fifo1() { } #[test] -#[cfg(target_os = "linux")] +#[cfg(all(unix, not(target_os = "android")))] fn test_stdin_pipe_fifo2() { // $ stat - // File: - @@ -402,16 +400,15 @@ fn test_stdin_pipe_fifo2() { } #[test] -#[cfg(target_os = "linux")] +#[cfg(all(unix, not(any(target_os = "android", target_os = "macos"))))] fn test_stdin_redirect() { // $ touch f && stat - < f // File: - // Size: 0 Blocks: 0 IO Block: 4096 regular empty file - let ts = TestScenario::new(util_name!()); let at = &ts.fixtures; at.touch("f"); - new_ucmd!() + ts.ucmd() .arg("-") .set_stdin(std::fs::File::open(at.plus("f")).unwrap()) .run()