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.
This commit is contained in:
Anund
2024-12-26 14:50:30 +11:00
parent b86d002db4
commit 41883db65e

View File

@ -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);