diff options
Diffstat (limited to 'test/snapshot.zig')
| -rw-r--r-- | test/snapshot.zig | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/test/snapshot.zig b/test/snapshot.zig index d93face2..26022a41 100644 --- a/test/snapshot.zig +++ b/test/snapshot.zig @@ -86,6 +86,9 @@ var careful = false; /// abs path of the deterministic mock language server the build handed over /// (--lspmock=); null leaves the protocol client fully disabled for the run var lspmock_bin: ?[:0]const u8 = null; +/// abs path of the image addon the build made (--image-addon=), linked into +/// each script's data directory, where a session's start scan finds it +var image_addon: ?[:0]const u8 = null; var record_dir: ?[]const u8 = null; /// --tape=DIR: each session records its tape there (PARDES_RECORD, src/tape.zig) /// and the script fails unless every tape replays without diverging. @@ -133,6 +136,8 @@ pub fn main(init: std.process.Init) !void { trace_stable = true; } else if (std.mem.startsWith(u8, a, "--lspmock=")) { lspmock = try absPath(arena, orig_cwd, a["--lspmock=".len..]); + } else if (std.mem.startsWith(u8, a, "--image-addon=")) { + image_addon = try arena.dupeSentinel(u8, try absPath(arena, orig_cwd, a["--image-addon=".len..]), 0); } else if (std.mem.startsWith(u8, a, "--record=")) { record_dir = try absPath(arena, orig_cwd, a["--record=".len..]); } else if (std.mem.startsWith(u8, a, "--tape=")) { @@ -165,6 +170,7 @@ pub fn main(init: std.process.Init) !void { std.mem.eql(u8, a, "--no-retry") or std.mem.eql(u8, a, "--trace-stable") or std.mem.startsWith(u8, a, "--lspmock=") or + std.mem.startsWith(u8, a, "--image-addon=") or std.mem.startsWith(u8, a, "--record=") or std.mem.startsWith(u8, a, "--tape=") or std.mem.eql(u8, a, "--dump") or @@ -628,6 +634,13 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const // XDG directory that points outside this per-snapshot fake home. const config_home = try std.fmt.allocPrintSentinel(arena, "{s}/.config", .{home}, 0); _ = setenv("XDG_CONFIG_HOME", config_home, 1); + // ...and its data directory (dumps, the addons its start scan loads). + const data_home = try std.fmt.allocPrintSentinel(arena, "{s}/.local/share", .{home}, 0); + _ = setenv("XDG_DATA_HOME", data_home, 1); + if (image_addon) |lib| { + for ([_][]const u8{ "/.local", "/.local/share", "/.local/share/pardes", "/.local/share/pardes/addons" }) |sub| try mkdir(arena, try std.fmt.allocPrint(arena, "{s}{s}", .{ home, sub }), true); + if (libc.symlink(lib, try std.fmt.allocPrintSentinel(arena, "{s}/pardes/addons/image.so", .{data_home}, 0)) != 0) return error.SymlinkFailed; + } // ...and it is not empty: the DEFAULT shell is $SHELL, whatever this // machine's user logs in with (fish's prompt carries a hostname and its // greeting a version), so a golden taken |
