From 7eb873c326188a6883b7c2117c72484bd7d36466 Mon Sep 17 00:00:00 2001 From: Nicolas Boichat Date: Sun, 23 Mar 2025 14:47:05 +0100 Subject: [PATCH] test_env: Try to execute an empty file instead of `.` For some unclear reason, Android _now_ sometimes returns an IsADirectory error, instead of PermissionDenied, when trying to execute `.`. Since this test really wants to test PermissionDenied, we try to execute a file in the fixture instead, that doesn't have exec permission. Also, limit this test to Unix. Fixes part of #7542. --- tests/by-util/test_env.rs | 6 ++++-- tests/fixtures/env/empty | 0 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 tests/fixtures/env/empty diff --git a/tests/by-util/test_env.rs b/tests/by-util/test_env.rs index 4a7ea96c0..1b8974a90 100644 --- a/tests/by-util/test_env.rs +++ b/tests/by-util/test_env.rs @@ -81,11 +81,13 @@ fn test_env_version() { } #[test] +#[cfg(unix)] fn test_env_permissions() { + // Try to execute `empty` in test fixture, that does not have exec permission. new_ucmd!() - .arg(".") + .arg("./empty") .fails_with_code(126) - .stderr_is("env: '.': Permission denied\n"); + .stderr_is("env: './empty': Permission denied\n"); } #[test] diff --git a/tests/fixtures/env/empty b/tests/fixtures/env/empty new file mode 100644 index 000000000..e69de29bb