From 5ef2da8127501083abdeb623df45674b7439ea45 Mon Sep 17 00:00:00 2001 From: Alessandro De Blasis Date: Mon, 23 Mar 2026 13:03:25 +0100 Subject: [PATCH] windows: fix XDG-related test failures on Windows Make the "cache directory paths" test cross-platform by using std.fs.path.join for expected values and a platform-appropriate mock home path, since the function under test uses native path separators. Skip the two shell integration XDG_DATA_DIRS tests on Windows. These tests use hardcoded Unix path separators (:) and Unix default paths (/usr/local/share:/usr/share) which are not applicable on Windows where the path delimiter is ; and XDG_DATA_DIRS is not a standard concept. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/os/xdg.zig | 10 +++++++--- src/termio/shell_integration.zig | 4 ++++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/os/xdg.zig b/src/os/xdg.zig index a813b0a98..f2a495af4 100644 --- a/src/os/xdg.zig +++ b/src/os/xdg.zig @@ -132,7 +132,7 @@ test { test "cache directory paths" { const testing = std.testing; const alloc = testing.allocator; - const mock_home = "/Users/test"; + const mock_home = if (builtin.os.tag == .windows) "C:\\Users\\test" else "/Users/test"; // Test when XDG_CACHE_HOME is not set { @@ -140,7 +140,9 @@ test "cache directory paths" { { const cache_path = try cache(alloc, .{ .home = mock_home }); defer alloc.free(cache_path); - try testing.expectEqualStrings("/Users/test/.cache", cache_path); + const expected = try std.fs.path.join(alloc, &.{ mock_home, ".cache" }); + defer alloc.free(expected); + try testing.expectEqualStrings(expected, cache_path); } // Test with subdir @@ -150,7 +152,9 @@ test "cache directory paths" { .subdir = "ghostty", }); defer alloc.free(cache_path); - try testing.expectEqualStrings("/Users/test/.cache/ghostty", cache_path); + const expected = try std.fs.path.join(alloc, &.{ mock_home, ".cache", "ghostty" }); + defer alloc.free(expected); + try testing.expectEqualStrings(expected, cache_path); } } } diff --git a/src/termio/shell_integration.zig b/src/termio/shell_integration.zig index e5b9eab10..2dd09ee29 100644 --- a/src/termio/shell_integration.zig +++ b/src/termio/shell_integration.zig @@ -670,6 +670,8 @@ fn setupXdgDataDirs( } test "xdg: empty XDG_DATA_DIRS" { + if (builtin.os.tag == .windows) return error.SkipZigTest; + const testing = std.testing; var arena = ArenaAllocator.init(testing.allocator); @@ -696,6 +698,8 @@ test "xdg: empty XDG_DATA_DIRS" { } test "xdg: existing XDG_DATA_DIRS" { + if (builtin.os.tag == .windows) return error.SkipZigTest; + const testing = std.testing; var arena = ArenaAllocator.init(testing.allocator);