diff --git a/lib/compiler/test_runner.zig b/lib/compiler/test_runner.zig index 5885f5cf12..c868bee6aa 100644 --- a/lib/compiler/test_runner.zig +++ b/lib/compiler/test_runner.zig @@ -129,6 +129,7 @@ fn mainServer(init: std.process.Init.Minimal) !void { }, .run_test => { + testing.environ = init.environ; testing.allocator_instance = .{}; testing.io_instance = .init(testing.allocator, .{ .argv0 = .init(init.args), @@ -244,6 +245,7 @@ fn mainTerminal(init: std.process.Init.Minimal) void { if (testing.allocator_instance.deinit() == .leak) leaks += 1; } testing.log_level = .warn; + testing.environ = init.environ; const test_node = root_node.start(test_fn.name, 0); if (!have_tty) { diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 561a6c7f8b..317256fcee 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -2,6 +2,7 @@ const builtin = @import("builtin"); const std = @import("std.zig"); const Io = std.Io; +const Environ = std.process.Environ; const assert = std.debug.assert; const math = std.math; @@ -33,6 +34,8 @@ pub var allocator_instance: std.heap.GeneralPurposeAllocator(.{ pub var io_instance: Io.Threaded = undefined; pub const io = if (builtin.is_test) io_instance.io() else @compileError("not testing"); +pub var environ: Environ = if (builtin.is_test) undefined else @compileError("not testing"); + /// TODO https://github.com/ziglang/zig/issues/5738 pub var log_level = std.log.Level.warn;