summaryrefslogtreecommitdiff
path: root/test/snapshot.zig
diff options
context:
space:
mode:
Diffstat (limited to 'test/snapshot.zig')
-rw-r--r--test/snapshot.zig24
1 files changed, 15 insertions, 9 deletions
diff --git a/test/snapshot.zig b/test/snapshot.zig
index 26022a41..51c81dd9 100644
--- a/test/snapshot.zig
+++ b/test/snapshot.zig
@@ -86,9 +86,10 @@ 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;
+/// abs paths of the addons the build made (--addon=, image and pdf), linked
+/// into each script's data directory, where a session's start scan finds them
+var addons: [4][:0]const u8 = undefined;
+var naddons: usize = 0;
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.
@@ -136,8 +137,10 @@ 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, "--addon=")) {
+ if (naddons == addons.len) return error.TooManyAddons;
+ addons[naddons] = try arena.dupeSentinel(u8, try absPath(arena, orig_cwd, a["--addon=".len..]), 0);
+ naddons += 1;
} 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=")) {
@@ -170,7 +173,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, "--addon=") or
std.mem.startsWith(u8, a, "--record=") or
std.mem.startsWith(u8, a, "--tape=") or
std.mem.eql(u8, a, "--dump") or
@@ -637,9 +640,12 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
// ...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;
+ if (naddons > 0) 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);
+ for (addons[0..naddons]) |lib| {
+ // libpdf.so as pdf.so: the name a build installs it as.
+ const file = std.fs.path.basename(lib);
+ const installed = if (std.mem.startsWith(u8, file, "lib")) file[3..] else file;
+ if (libc.symlink(lib, try std.fmt.allocPrintSentinel(arena, "{s}/pardes/addons/{s}", .{ data_home, installed }, 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