mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-10-17 07:16:12 +00:00
Merge pull request #704 from der-teufel-programming/windows-test
Get `zig build test` working on Windows
This commit is contained in:
@@ -355,6 +355,7 @@ 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" },
|
||||
@@ -375,6 +376,7 @@ test "Command: pre exec" {
|
||||
}
|
||||
|
||||
test "Command: redirect stdout to file" {
|
||||
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
||||
var td = try TempDir.init();
|
||||
defer td.deinit();
|
||||
var stdout = try td.dir.createFile("stdout.txt", .{ .read = true });
|
||||
@@ -400,6 +402,7 @@ test "Command: redirect stdout to file" {
|
||||
}
|
||||
|
||||
test "Command: custom env vars" {
|
||||
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
||||
var td = try TempDir.init();
|
||||
defer td.deinit();
|
||||
var stdout = try td.dir.createFile("stdout.txt", .{ .read = true });
|
||||
@@ -430,6 +433,7 @@ test "Command: custom env vars" {
|
||||
}
|
||||
|
||||
test "Command: custom working directory" {
|
||||
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
||||
var td = try TempDir.init();
|
||||
defer td.deinit();
|
||||
var stdout = try td.dir.createFile("stdout.txt", .{ .read = true });
|
||||
|
@@ -128,6 +128,7 @@ pub fn childPreExec(self: Pty) !void {
|
||||
}
|
||||
|
||||
test {
|
||||
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
||||
var ws: winsize = .{
|
||||
.ws_row = 50,
|
||||
.ws_col = 80,
|
||||
|
@@ -41,6 +41,9 @@ pub fn launchedFromDesktop() bool {
|
||||
break :linux gio_pid == pid;
|
||||
},
|
||||
|
||||
// TODO: This should have some logic to detect this. Perhaps std.builtin.subsystem
|
||||
.windows => false,
|
||||
|
||||
else => @compileError("unsupported platform"),
|
||||
};
|
||||
}
|
||||
|
@@ -138,6 +138,7 @@ pub fn get(alloc: Allocator) !Entry {
|
||||
}
|
||||
|
||||
test {
|
||||
if (builtin.os.tag == .windows) return error.SkipZigTest;
|
||||
const testing = std.testing;
|
||||
var arena = ArenaAllocator.init(testing.allocator);
|
||||
defer arena.deinit();
|
||||
|
@@ -20,7 +20,22 @@ pub const Options = struct {
|
||||
|
||||
/// Get the XDG user config directory. The returned value is allocated.
|
||||
pub fn config(alloc: Allocator, opts: Options) ![]u8 {
|
||||
if (std.os.getenv("XDG_CONFIG_HOME")) |env| {
|
||||
// First check the env var. On Windows we have to allocate so this tracks
|
||||
// both whether we have the env var and whether we own it.
|
||||
const env_, const owned = switch (builtin.os.tag) {
|
||||
else => .{ std.os.getenv("XDG_CONFIG_HOME"), false },
|
||||
.windows => windows: {
|
||||
if (std.process.getEnvVarOwned(alloc, "XDG_CONFIG_HOME")) |env| {
|
||||
break :windows .{ env, true };
|
||||
} else |err| switch (err) {
|
||||
error.EnvironmentVariableNotFound => break :windows .{ null, false },
|
||||
else => return err,
|
||||
}
|
||||
},
|
||||
};
|
||||
defer if (owned) if (env_) |v| alloc.free(v);
|
||||
|
||||
if (env_) |env| {
|
||||
// If we have a subdir, then we use the env as-is to avoid a copy.
|
||||
if (opts.subdir) |subdir| {
|
||||
return try std.fs.path.join(alloc, &[_][]const u8{
|
||||
|
Reference in New Issue
Block a user