mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
testing: point Command.zig at ~more universal external binaries
The `Command.zig` tests reach outside the local source tree and look for files on the host os machine. This introduces some portability issues for the tests. The nix build sandbox doesn't include `/usr/bin/env` making it error out when `zig build test` runs `Command.zig` tests as part of a `nix build`. Current ci and local development relies on `nix develop` sharing a host os file system that includes `/usr/bin/env`. Turns out `/tmp` and `/bin/sh` are available in the build sandbox in nix so we swap these in to enable nixpkg builds to include testing ghostty as part of any update cycle.
This commit is contained in:
@ -587,8 +587,8 @@ test "createNullDelimitedEnvMap" {
|
|||||||
test "Command: pre exec" {
|
test "Command: pre exec" {
|
||||||
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
||||||
var cmd: Command = .{
|
var cmd: Command = .{
|
||||||
.path = "/usr/bin/env",
|
.path = "/bin/sh",
|
||||||
.args = &.{ "/usr/bin/env", "-v" },
|
.args = &.{ "/bin/sh", "-v" },
|
||||||
.pre_exec = (struct {
|
.pre_exec = (struct {
|
||||||
fn do(_: *Command) void {
|
fn do(_: *Command) void {
|
||||||
// This runs in the child, so we can exit and it won't
|
// This runs in the child, so we can exit and it won't
|
||||||
@ -629,8 +629,8 @@ test "Command: redirect stdout to file" {
|
|||||||
.args = &.{"C:\\Windows\\System32\\whoami.exe"},
|
.args = &.{"C:\\Windows\\System32\\whoami.exe"},
|
||||||
.stdout = stdout,
|
.stdout = stdout,
|
||||||
} else .{
|
} else .{
|
||||||
.path = "/usr/bin/env",
|
.path = "/bin/sh",
|
||||||
.args = &.{ "/usr/bin/env", "-v" },
|
.args = &.{ "/bin/sh", "-c", "echo hello" },
|
||||||
.stdout = stdout,
|
.stdout = stdout,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -663,8 +663,8 @@ test "Command: custom env vars" {
|
|||||||
.stdout = stdout,
|
.stdout = stdout,
|
||||||
.env = &env,
|
.env = &env,
|
||||||
} else .{
|
} else .{
|
||||||
.path = "/usr/bin/env",
|
.path = "/bin/sh",
|
||||||
.args = &.{ "/usr/bin/env", "sh", "-c", "echo $VALUE" },
|
.args = &.{ "/bin/sh", "-c", "echo $VALUE" },
|
||||||
.stdout = stdout,
|
.stdout = stdout,
|
||||||
.env = &env,
|
.env = &env,
|
||||||
};
|
};
|
||||||
@ -699,10 +699,10 @@ test "Command: custom working directory" {
|
|||||||
.stdout = stdout,
|
.stdout = stdout,
|
||||||
.cwd = "C:\\Windows\\System32",
|
.cwd = "C:\\Windows\\System32",
|
||||||
} else .{
|
} else .{
|
||||||
.path = "/usr/bin/env",
|
.path = "/bin/sh",
|
||||||
.args = &.{ "/usr/bin/env", "sh", "-c", "pwd" },
|
.args = &.{ "/bin/sh", "-c", "pwd" },
|
||||||
.stdout = stdout,
|
.stdout = stdout,
|
||||||
.cwd = "/usr/bin",
|
.cwd = "/tmp",
|
||||||
};
|
};
|
||||||
|
|
||||||
try cmd.testingStart();
|
try cmd.testingStart();
|
||||||
@ -718,8 +718,10 @@ test "Command: custom working directory" {
|
|||||||
|
|
||||||
if (builtin.os.tag == .windows) {
|
if (builtin.os.tag == .windows) {
|
||||||
try testing.expectEqualStrings("C:\\Windows\\System32\r\n", contents);
|
try testing.expectEqualStrings("C:\\Windows\\System32\r\n", contents);
|
||||||
|
} else if (builtin.os.tag == .macos) {
|
||||||
|
try testing.expectEqualStrings("/private/tmp\n", contents);
|
||||||
} else {
|
} else {
|
||||||
try testing.expectEqualStrings("/usr/bin\n", contents);
|
try testing.expectEqualStrings("/tmp\n", contents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user