authorgravatar for leecannon@leecannon.xyzLee Cannon <leecannon@leecannon.xyz> 2022-01-20 03:42:27+00:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-01-24 17:29:19+02:00
logc54a7ca4b25a0ffe080a80fb19986142c98b124e
tree1ffc8c926c86f5f37487f6925c19841314b0499c
parent12c2de6ee205857e9ca0bcef4aa4d901fc5cc772

allow `expected_exit_code` to be `null`


1 files changed, 8 insertions(+), 5 deletions(-)

lib/std/build/RunStep.zig+8-5
......@@ -34,7 +34,8 @@ stderr_action: StdIoAction = .inherit,
3434
3535stdin_behavior: std.ChildProcess.StdIo = .Inherit,
3636
37expected_exit_code: u8 = 0,
37/// Set this to `null` to ignore the exit code for the purpose of determining a successful execution
38expected_exit_code: ?u8 = 0,
3839
3940/// Print the command before running it
4041print: bool,
......@@ -220,17 +221,19 @@ fn make(step: *Step) !void {
220221 };
221222
222223 switch (term) {
223 .Exited => |code| {
224 if (code != self.expected_exit_code) {
224 .Exited => |code| blk: {
225 const expected_exit_code = self.expected_exit_code orelse break :blk;
226
227 if (code != expected_exit_code) {
225228 if (self.builder.prominent_compile_errors) {
226229 std.debug.print("Run step exited with error code {} (expected {})\n", .{
227230 code,
228 self.expected_exit_code,
231 expected_exit_code,
229232 });
230233 } else {
231234 std.debug.print("The following command exited with error code {} (expected {}):\n", .{
232235 code,
233 self.expected_exit_code,
236 expected_exit_code,
234237 });
235238 printCmd(cwd, argv);
236239 }