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,...@@ -34,7 +34,8 @@ stderr_action: StdIoAction = .inherit,
3434
35stdin_behavior: std.ChildProcess.StdIo = .Inherit,35stdin_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
39/// Print the command before running it40/// Print the command before running it
40print: bool,41print: bool,
...@@ -220,17 +221,19 @@ fn make(step: *Step) !void {...@@ -220,17 +221,19 @@ fn make(step: *Step) !void {
220 };221 };
221222
222 switch (term) {223 switch (term) {
223 .Exited => |code| {224 .Exited => |code| blk: {
224 if (code != self.expected_exit_code) {225 const expected_exit_code = self.expected_exit_code orelse break :blk;
226
227 if (code != expected_exit_code) {
225 if (self.builder.prominent_compile_errors) {228 if (self.builder.prominent_compile_errors) {
226 std.debug.print("Run step exited with error code {} (expected {})\n", .{229 std.debug.print("Run step exited with error code {} (expected {})\n", .{
227 code,230 code,
228 self.expected_exit_code,231 expected_exit_code,
229 });232 });
230 } else {233 } else {
231 std.debug.print("The following command exited with error code {} (expected {}):\n", .{234 std.debug.print("The following command exited with error code {} (expected {}):\n", .{
232 code,235 code,
233 self.expected_exit_code,236 expected_exit_code,
234 });237 });
235 printCmd(cwd, argv);238 printCmd(cwd, argv);
236 }239 }