diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2019-03-11 11:56:08 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2019-03-11 11:56:08 -0400 |
| commit | e1fbb24d64caa956846405bd42aed59e5b9513f2 (patch) | |
| tree | 86a1d3151a5431a7578339fc2a967fb234b27f2f /test/standalone | |
| parent | b4e6e301e1a5411d09a306fb96cf4a5c8d0b754f (diff) | |
| download | zig-e1fbb24d64caa956846405bd42aed59e5b9513f2.tar.gz zig-e1fbb24d64caa956846405bd42aed59e5b9513f2.zip | |
add test for spawning child process with empty environment
thanks to BenoitJGirard for pointing out the child process
implementation needs 3 extra null bytes in #2031
Diffstat (limited to 'test/standalone')
| -rw-r--r-- | test/standalone/empty_env/build.zig | 12 | ||||
| -rw-r--r-- | test/standalone/empty_env/main.zig | 6 |
2 files changed, 18 insertions, 0 deletions
diff --git a/test/standalone/empty_env/build.zig b/test/standalone/empty_env/build.zig new file mode 100644 index 0000000000..2a184dcd2e --- /dev/null +++ b/test/standalone/empty_env/build.zig @@ -0,0 +1,12 @@ +const Builder = @import("std").build.Builder; + +pub fn build(b: *Builder) void { + const main = b.addExecutable("main", "main.zig"); + main.setBuildMode(b.standardReleaseOptions()); + + const run = main.run(); + run.clearEnvironment(); + + const test_step = b.step("test", "Test it"); + test_step.dependOn(&run.step); +} diff --git a/test/standalone/empty_env/main.zig b/test/standalone/empty_env/main.zig new file mode 100644 index 0000000000..20b45c3137 --- /dev/null +++ b/test/standalone/empty_env/main.zig @@ -0,0 +1,6 @@ +const std = @import("std"); + +pub fn main() void { + const env_map = std.os.getEnvMap(std.debug.global_allocator) catch @panic("unable to get env map"); + std.testing.expect(env_map.count() == 0); +} |
