zig/test/standalone/self_exe_symlink/create-symlink.zig
Ryan Liptak 47343f9bcf Add self_exe_symlink standalone test
Tests that fs.selfExePath follows symlinks by comparing it to the path of the File returned from fs.openSelfExe
2023-08-19 17:48:19 -07:00

15 lines
529 B
Zig

const std = @import("std");
pub fn main() anyerror!void {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
defer if (gpa.deinit() == .leak) @panic("found memory leaks");
const allocator = gpa.allocator();
var it = try std.process.argsWithAllocator(allocator);
defer it.deinit();
_ = it.next() orelse unreachable; // skip binary name
const exe_path = it.next() orelse unreachable;
const symlink_path = it.next() orelse unreachable;
try std.fs.cwd().symLink(exe_path, symlink_path, .{});
}