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