command: fix hostname test compatibility

hostname is not guaranteed on *nix as in the comment.
For example, Arch does not have hostname by default.
This commit is contained in:
Khang Nguyen Duy
2024-12-11 16:47:20 +07:00
parent 59df17a699
commit cb5848c7b7

View File

@ -440,9 +440,9 @@ fn isExecutable(mode: std.fs.File.Mode) bool {
return mode & 0o0111 != 0;
}
// `hostname` is present on both *nix and windows
// `uname -n` is the *nix equivalent of `hostname.exe` on Windows
test "expandPath: hostname" {
const executable = if (builtin.os.tag == .windows) "hostname.exe" else "hostname";
const executable = if (builtin.os.tag == .windows) "hostname.exe" else "uname";
const path = (try expandPath(testing.allocator, executable)).?;
defer testing.allocator.free(path);
try testing.expect(path.len > executable.len);