Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/+proc-which-direct.misc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`proc.which` tests cover executable resolution and null returns for non-executable candidates.
16 changes: 16 additions & 0 deletions src/proc.zig
Original file line number Diff line number Diff line change
Expand Up @@ -806,3 +806,19 @@ test "resolveExecutable handles relative slash paths" {
defer gpa.free(rel_plain);
try std.testing.expectEqual(@as(?[]u8, null), try resolveExecutable(gpa, rel_plain, null));
}

test "which resolves executable candidates directly" {
const gpa = std.testing.allocator;
const fixture = try makeExecFixture(gpa, "which");
defer gpa.free(fixture.plain_path);
defer gpa.free(fixture.exe_path);
defer gpa.free(fixture.base);
defer fsx.deleteTree(gpa, fsx.cwd, fixture.base) catch {};

const found = (try which(gpa, "tool.sh", fixture.base)).?;
defer gpa.free(found);
try std.testing.expectEqualStrings(fixture.exe_path, found);

try std.testing.expectEqual(@as(?[]u8, null), try which(gpa, "plain.txt", fixture.base));
try std.testing.expectEqual(@as(?[]u8, null), try which(gpa, "not-present-tool", fixture.base));
}
Loading