From 8a985236af9c83ec81389367b2c61d62c90e21ee Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Tue, 27 Jan 2026 11:29:03 -0800 Subject: [PATCH] std.Build.Step.Run: gracefully handle test runner misbehavior specifically if it misbehaves after sending a message header but not the body --- lib/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 index a2d678275a..4d3cda54c9 100644 --- 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);