ReviewOS

also looking at this

zig-utils/zig-test-framework

Add Windows support and CI coverage

#24
Merged glennmichael123 wants to merge codex/issue-6-windows-support into main
6 files +170 -266
src/discovery.zigmodified+15-5
Changes to src/discovery.zig
@@ -119,11 +119,7 @@ fn scanDirectory(
119119 else
120120 full_path;
121121
122 // Skip leading slash in relative path
123 const clean_relative = if (relative_path.len > 0 and relative_path[0] == '/')
124 relative_path[1..]
125 else
126 relative_path;
122 const clean_relative = cleanRelativePath(relative_path);
127123
128124 try result.addFile(full_path, clean_relative, entry.name);
129125 }
@@ -135,6 +131,15 @@ fn scanDirectory(
135131 }
136132}
137133
134/// Removes separators introduced by slicing the root prefix. Accept both
135/// spellings so paths remain stable when a project moves between POSIX and
136/// Windows hosts.
137fn cleanRelativePath(path: []const u8) []const u8 {
138 var start: usize = 0;
139 while (start < path.len and (path[start] == '/' or path[start] == '\\')) : (start += 1) {}
140 return path[start..];
141}
142
138143/// Check if a filename matches the pattern
139144fn matchesPattern(filename: []const u8, pattern: []const u8) bool {
140145 // Simple pattern matching - check if filename ends with pattern
@@ -160,3 +165,8 @@ test "matchesPattern with exact match" {
160165 try std.testing.expect(matchesPattern("test.zig", "test.zig"));
161166 try std.testing.expect(!matchesPattern("other.zig", "test.zig"));
162167}
168
169test "relative paths discard POSIX and Windows separators" {
170 try std.testing.expectEqualStrings("suite/sample.test.zig", cleanRelativePath("/suite/sample.test.zig"));
171 try std.testing.expectEqualStrings("suite\\sample.test.zig", cleanRelativePath("\\suite\\sample.test.zig"));
172}