From 41883db65e883c1802abfef3ba75a014e4dbf178 Mon Sep 17 00:00:00 2001 From: Anund Date: Thu, 26 Dec 2024 14:50:30 +1100 Subject: [PATCH] testing: update tests to point a ~real binary `/usr/bin/env` does not exist in a nix build sandbox. This only works as a test binary when running in `nix develop` as it shares its environment with the user `/bin/sh` isn't amazing as a target as it's relying on stdenv creating it in a build sandbox and users having while running `nix develop`. Alternatives require build flags or some sort of contract with packaging. --- src/Command.zig | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Command.zig b/src/Command.zig index 47332d06c..5b59ac8f9 100644 --- a/src/Command.zig +++ b/src/Command.zig @@ -588,8 +588,8 @@ test "createNullDelimitedEnvMap" { test "Command: pre exec" { if (builtin.os.tag == .windows) return error.SkipZigTest; var cmd: Command = .{ - .path = "/usr/bin/env", - .args = &.{ "/usr/bin/env", "-v" }, + .path = "/bin/sh", + .args = &.{ "/bin/sh", "--help" }, .pre_exec = (struct { fn do(_: *Command) void { // This runs in the child, so we can exit and it won't @@ -630,8 +630,8 @@ test "Command: redirect stdout to file" { .args = &.{"C:\\Windows\\System32\\whoami.exe"}, .stdout = stdout, } else .{ - .path = "/usr/bin/env", - .args = &.{ "/usr/bin/env", "-v" }, + .path = "/bin/sh", + .args = &.{ "/bin/sh", "-c", "echo hello" }, .stdout = stdout, }; @@ -664,8 +664,8 @@ test "Command: custom env vars" { .stdout = stdout, .env = &env, } else .{ - .path = "/usr/bin/env", - .args = &.{ "/usr/bin/env", "sh", "-c", "echo $VALUE" }, + .path = "/bin/sh", + .args = &.{ "/bin/sh", "-c", "echo $VALUE" }, .stdout = stdout, .env = &env, }; @@ -700,10 +700,10 @@ test "Command: custom working directory" { .stdout = stdout, .cwd = "C:\\Windows\\System32", } else .{ - .path = "/usr/bin/env", - .args = &.{ "/usr/bin/env", "sh", "-c", "pwd" }, + .path = "/bin/sh", + .args = &.{ "/bin/sh", "-c", "pwd" }, .stdout = stdout, - .cwd = "/usr/bin", + .cwd = "/bin", }; try cmd.start(testing.allocator);