| ... | @@ -59,6 +59,7 @@ result_duration_ns: ?u64 = null, | ... | @@ -59,6 +59,7 @@ result_duration_ns: ?u64 = null, |
| 59 | result_peak_rss: usize = 0, | 59 | result_peak_rss: usize = 0, |
| 60 | /// If the step is failed and this field is populated, this is the command which failed. | 60 | /// If the step is failed and this field is populated, this is the command which failed. |
| 61 | /// This field may be populated even if the step succeeded. | 61 | /// This field may be populated even if the step succeeded. |
| | 62 | /// Memory owned by `Maker.gpa`. |
| 62 | result_failed_command: ?[]const u8 = null, | 63 | result_failed_command: ?[]const u8 = null, |
| 63 | test_results: TestResults = .{}, | 64 | test_results: TestResults = .{}, |
| 64 | | 65 | |
| ... | @@ -313,14 +314,13 @@ pub fn reset(step: *Step, maker: *Maker) void { | ... | @@ -313,14 +314,13 @@ pub fn reset(step: *Step, maker: *Maker) void { |
| 313 | assert(step.state == .precheck_done); | 314 | assert(step.state == .precheck_done); |
| 314 | const gpa = maker.gpa; | 315 | const gpa = maker.gpa; |
| 315 | | 316 | |
| 316 | if (step.result_failed_command) |cmd| gpa.free(cmd); | 317 | clearFailedCommand(step, gpa); |
| 317 | | 318 | |
| 318 | step.result_error_msgs.clearRetainingCapacity(); | 319 | step.result_error_msgs.clearRetainingCapacity(); |
| 319 | step.result_stderr = ""; | 320 | step.result_stderr = ""; |
| 320 | step.result_cached = false; | 321 | step.result_cached = false; |
| 321 | step.result_duration_ns = null; | 322 | step.result_duration_ns = null; |
| 322 | step.result_peak_rss = 0; | 323 | step.result_peak_rss = 0; |
| 323 | step.result_failed_command = null; | | |
| 324 | step.test_results = .{}; | 324 | step.test_results = .{}; |
| 325 | // We do not clearWatchInputs here because each step manages that choice | 325 | // We do not clearWatchInputs here because each step manages that choice |
| 326 | // independently. | 326 | // independently. |
| ... | @@ -347,8 +347,7 @@ pub fn captureChildProcess(s: *Step, maker: *Maker, options: CaptureChildProcess | ... | @@ -347,8 +347,7 @@ pub fn captureChildProcess(s: *Step, maker: *Maker, options: CaptureChildProcess |
| 347 | const arena = graph.arena; // TODO stop leaking into process arena | 347 | const arena = graph.arena; // TODO stop leaking into process arena |
| 348 | const io = graph.io; | 348 | const io = graph.io; |
| 349 | | 349 | |
| 350 | // If an error occurs, it's happened in this command: | 350 | clearFailedCommand(s, gpa); |
| 351 | assert(s.result_failed_command == null); | | |
| 352 | s.result_failed_command = try std.zig.allocPrintCmd(gpa, options.argv, .{}); | 351 | s.result_failed_command = try std.zig.allocPrintCmd(gpa, options.argv, .{}); |
| 353 | | 352 | |
| 354 | try handleChildProcUnsupported(s, maker); | 353 | try handleChildProcUnsupported(s, maker); |
| ... | @@ -372,6 +371,11 @@ pub fn captureChildProcess(s: *Step, maker: *Maker, options: CaptureChildProcess | ... | @@ -372,6 +371,11 @@ pub fn captureChildProcess(s: *Step, maker: *Maker, options: CaptureChildProcess |
| 372 | return result; | 371 | return result; |
| 373 | } | 372 | } |
| 374 | | 373 | |
| | 374 | fn clearFailedCommand(s: *Step, gpa: Allocator) void { |
| | 375 | if (s.result_failed_command) |cmd| gpa.free(cmd); |
| | 376 | s.result_failed_command = null; |
| | 377 | } |
| | 378 | |
| 375 | pub const FailError = error{ OutOfMemory, MakeFailed }; | 379 | pub const FailError = error{ OutOfMemory, MakeFailed }; |
| 376 | | 380 | |
| 377 | pub fn fail(step: *Step, maker: *const Maker, comptime fmt: []const u8, args: anytype) FailError { | 381 | pub fn fail(step: *Step, maker: *const Maker, comptime fmt: []const u8, args: anytype) FailError { |
| ... | @@ -421,7 +425,7 @@ pub fn evalZigProcess( | ... | @@ -421,7 +425,7 @@ pub fn evalZigProcess( |
| 421 | const io = graph.io; | 425 | const io = graph.io; |
| 422 | | 426 | |
| 423 | // If an error occurs, it's happened in this command: | 427 | // If an error occurs, it's happened in this command: |
| 424 | assert(s.result_failed_command == null); | 428 | clearFailedCommand(s, gpa); |
| 425 | s.result_failed_command = try std.zig.allocPrintCmd(gpa, argv, .{}); | 429 | s.result_failed_command = try std.zig.allocPrintCmd(gpa, argv, .{}); |
| 426 | | 430 | |
| 427 | if (s.getZigProcess()) |zp| update: { | 431 | if (s.getZigProcess()) |zp| update: { |