Skip to content

Commit f13401a

Browse files
McSinyxVexu
authored andcommitted
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.
1 parent 4b1edad commit f13401a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/std/Build/Step/Run.zig

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,7 +1181,9 @@ fn evalZigTest(
11811181

11821182
if (tr_hdr.flags.fail or tr_hdr.flags.leak or tr_hdr.flags.log_err_count > 0) {
11831183
const name = std.mem.sliceTo(md.string_bytes[md.names[tr_hdr.index]..], 0);
1184-
const msg = std.mem.trim(u8, stderr.readableSlice(0), "\n");
1184+
const orig_msg = stderr.readableSlice(0);
1185+
defer stderr.discard(orig_msg.len);
1186+
const msg = std.mem.trim(u8, orig_msg, "\n");
11851187
const label = if (tr_hdr.flags.fail)
11861188
"failed"
11871189
else if (tr_hdr.flags.leak)
@@ -1195,7 +1197,6 @@ fn evalZigTest(
11951197
} else {
11961198
try self.step.addError("'{s}' {s}", .{ name, label });
11971199
}
1198-
stderr.discard(msg.len);
11991200
}
12001201

12011202
try requestNextTest(child.stdin.?, &metadata.?, &sub_prog_node);

0 commit comments

Comments
 (0)