Fix standalone test simple/cat/main.zig after Writergate update (#25188)

* Make cat in test/standalone/simple working again

- Fixes:
    zig/0.15.1/lib/zig/std/Io/Writer.zig:939:11: 0x1049aef63 in sendFileAll (nclip)
        assert(w.buffer.len > 0);
- because we are no using non zero buffers for stdout - "do not forget to flush"

* replace std.fs with fs because we are already importing it
This commit is contained in:
Sardorbek Imomaliev 2025-09-11 17:43:11 +01:00 committed by GitHub
parent fb3afc8d3d
commit 6b8cef8107
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,9 +13,10 @@ pub fn main() !void {
const exe = args[0];
var catted_anything = false;
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
var stdout_buffer: [4096]u8 = undefined;
var stdout_writer = fs.File.stdout().writerStreaming(&stdout_buffer);
const stdout = &stdout_writer.interface;
var stdin_reader = std.fs.File.stdin().readerStreaming(&.{});
var stdin_reader = fs.File.stdin().readerStreaming(&.{});
const cwd = fs.cwd();
@ -23,6 +24,7 @@ pub fn main() !void {
if (mem.eql(u8, arg, "-")) {
catted_anything = true;
_ = try stdout.sendFileAll(&stdin_reader, .unlimited);
try stdout.flush();
} else if (mem.startsWith(u8, arg, "-")) {
return usage(exe);
} else {
@ -32,10 +34,12 @@ pub fn main() !void {
catted_anything = true;
var file_reader = file.reader(&.{});
_ = try stdout.sendFileAll(&file_reader, .unlimited);
try stdout.flush();
}
}
if (!catted_anything) {
_ = try stdout.sendFileAll(&stdin_reader, .unlimited);
try stdout.flush();
}
}