zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit efa502a1cd0333860848c2b6e15978f6551e02f3 (tree)
parent 523aa213c9f7466bdff5c7030de7d221f1547621
Author: Andrew Kelley <andrew@ziglang.org>
Date:   Tue, 27 Jan 2026 11:29:03 -0800

std.Build.Step.Run: gracefully handle test runner misbehavior

specifically if it misbehaves after sending a message header but not the
body

Diffstat:
Mlib/std/Build/Step/Run.zig | 23++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig @@ -1930,7 +1930,28 @@ fn waitZigTest( } // There is definitely a header available now -- read it. const header = stdout.takeStruct(Header, .little) catch unreachable; - try stdout.fill(header.bytes_len); + + while (stdout.buffered().len < header.bytes_len) { + const timeout: Io.Timeout = t: { + const t = if (timer) |*t| t else break :t .none; + if (response_timeout_ns) |timeout_ns| break :t .{ .duration = .{ + .raw = .fromNanoseconds(timeout_ns -| t.read()), + .clock = .awake, + } }; + break :t .none; + }; + multi_reader.fill(64, timeout) catch |err| switch (err) { + error.Timeout, error.EndOfStream => return .{ .no_poll = .{ + .active_test_index = active_test_index, + .ns_elapsed = if (timer) |*t| t.read() else 0, + } }, + error.UnsupportedClock => { + timer = null; + continue; + }, + else => |e| return e, + }; + } const body = stdout.take(header.bytes_len) catch unreachable; var body_r: std.Io.Reader = .fixed(body);