| author | |
| committer | |
| log | e1fbb24d64caa956846405bd42aed59e5b9513f2 |
| tree | 86a1d3151a5431a7578339fc2a967fb234b27f2f |
| parent | b4e6e301e1a5411d09a306fb96cf4a5c8d0b754f |
| signature |
thanks to BenoitJGirard for pointing out the child process
implementation needs 3 extra null bytes in #20314 files changed, 25 insertions(+), 0 deletions(-)
std/build.zig+6| ... | ... | @@ -1530,6 +1530,12 @@ pub const RunStep = struct { |
| 1530 | 1530 | } |
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | pub fn clearEnvironment(self: *RunStep) void { | |
| 1534 | const new_env_map = self.builder.allocator.create(BufMap) catch unreachable; | |
| 1535 | new_env_map.* = BufMap.init(self.builder.allocator); | |
| 1536 | self.env_map = new_env_map; | |
| 1537 | } | |
| 1538 | ||
| 1533 | 1539 | pub fn addPathDir(self: *RunStep, search_path: []const u8) void { |
| 1534 | 1540 | const PATH = if (builtin.os == builtin.Os.windows) "Path" else "PATH"; |
| 1535 | 1541 | const env_map = self.getEnvMap(); |
test/build_examples.zig+1| ... | ... | @@ -19,6 +19,7 @@ pub fn addCases(cases: *tests.BuildExamplesContext) void { |
| 19 | 19 | cases.addBuildFile("test/standalone/pkg_import/build.zig"); |
| 20 | 20 | cases.addBuildFile("test/standalone/use_alias/build.zig"); |
| 21 | 21 | cases.addBuildFile("test/standalone/brace_expansion/build.zig"); |
| 22 | cases.addBuildFile("test/standalone/empty_env/build.zig"); | |
| 22 | 23 | if (false) { |
| 23 | 24 | // TODO this test is disabled because it is failing on the CI server's linux. when this is fixed |
| 24 | 25 | // enable it for at least linux |
test/standalone/empty_env/build.zig created+12| ... | ... | @@ -0,0 +1,12 @@ |
| 1 | const Builder = @import("std").build.Builder; | |
| 2 | ||
| 3 | pub fn build(b: *Builder) void { | |
| 4 | const main = b.addExecutable("main", "main.zig"); | |
| 5 | main.setBuildMode(b.standardReleaseOptions()); | |
| 6 | ||
| 7 | const run = main.run(); | |
| 8 | run.clearEnvironment(); | |
| 9 | ||
| 10 | const test_step = b.step("test", "Test it"); | |
| 11 | test_step.dependOn(&run.step); | |
| 12 | } |
test/standalone/empty_env/main.zig created+6| ... | ... | @@ -0,0 +1,6 @@ |
| 1 | const std = @import("std"); | |
| 2 | ||
| 3 | pub fn main() void { | |
| 4 | const env_map = std.os.getEnvMap(std.debug.global_allocator) catch @panic("unable to get env map"); | |
| 5 | std.testing.expect(env_map.count() == 0); | |
| 6 | } |