From f13401ac695e2e79cda40b2a6f5cf6906fca5623 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Gia=20Phong?= Date: Wed, 28 Feb 2024 11:08:53 +0900 Subject: [PATCH] Fix stuttering stderr in Zig test log Before this fix, the stderr FIFO was advanced by the length of the trimmed message, thus the next error log contained the tail of that message. --- lib/std/Build/Step/Run.zig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig index 6364ec0ecf..b0b5602a12 100644 --- a/lib/std/Build/Step/Run.zig +++ b/lib/std/Build/Step/Run.zig @@ -1181,7 +1181,9 @@ fn evalZigTest( if (tr_hdr.flags.fail or tr_hdr.flags.leak or tr_hdr.flags.log_err_count > 0) { const name = std.mem.sliceTo(md.string_bytes[md.names[tr_hdr.index]..], 0); - const msg = std.mem.trim(u8, stderr.readableSlice(0), "\n"); + const orig_msg = stderr.readableSlice(0); + defer stderr.discard(orig_msg.len); + const msg = std.mem.trim(u8, orig_msg, "\n"); const label = if (tr_hdr.flags.fail) "failed" else if (tr_hdr.flags.leak) @@ -1195,7 +1197,6 @@ fn evalZigTest( } else { try self.step.addError("'{s}' {s}", .{ name, label }); } - stderr.discard(msg.len); } try requestNextTest(child.stdin.?, &metadata.?, &sub_prog_node);