summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/image_harness.zig4
-rw-r--r--test/snapshot.zig4
2 files changed, 8 insertions, 0 deletions
diff --git a/test/image_harness.zig b/test/image_harness.zig
index 390c14e8..bd465e1c 100644
--- a/test/image_harness.zig
+++ b/test/image_harness.zig
@@ -40,6 +40,10 @@ pub fn main(init: std.process.Init) !void {
if (libc.mkdir(base, 0o755) != 0 and libc.errno(-1) != .EXIST) return error.MkdirFailed;
defer cleanupBase(arena, base);
_ = setenv("HOME", base, 1);
+ // Do not let an exported developer XDG_CONFIG_HOME style or mutate the
+ // native process under test; this nonexistent directory is test-owned.
+ const config_home = try std.fmt.allocPrintSentinel(arena, "{s}/.config", .{base}, 0);
+ _ = setenv("XDG_CONFIG_HOME", config_home, 1);
_ = setenv("HISTFILE", "/dev/null", 1);
_ = setenv("TERM", "xterm-256color", 1);
_ = setenv("LC_ALL", "C", 1);
diff --git a/test/snapshot.zig b/test/snapshot.zig
index 19b65a02..7c00b97c 100644
--- a/test/snapshot.zig
+++ b/test/snapshot.zig
@@ -307,6 +307,10 @@ fn runScript(arena: std.mem.Allocator, exe_z: [:0]const u8, script_path: []const
// deterministic shell: fixed prompt, no history, no user rc leakage
try eh.writeFile(try std.fmt.allocPrintSentinel(arena, "{s}/.bashrc", .{home}, 0), "PS1='$ '\nHISTFILE=\n");
_ = setenv("HOME", try arena.dupeZ(u8, home), 1);
+ // Keep startup configuration hermetic even when the developer exports an
+ // 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);
_ = setenv("TERM", "xterm-256color", 1);
_ = setenv("LC_ALL", "C", 1);
// durations cannot live in a golden; the lsp introspection views print