Skip to content

Commit 6b8cef8

Browse files
authored
Fix standalone test simple/cat/main.zig after Writergate update (ziglang#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
1 parent fb3afc8 commit 6b8cef8

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/standalone/simple/cat/main.zig

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@ pub fn main() !void {
1313

1414
const exe = args[0];
1515
var catted_anything = false;
16-
var stdout_writer = std.fs.File.stdout().writerStreaming(&.{});
16+
var stdout_buffer: [4096]u8 = undefined;
17+
var stdout_writer = fs.File.stdout().writerStreaming(&stdout_buffer);
1718
const stdout = &stdout_writer.interface;
18-
var stdin_reader = std.fs.File.stdin().readerStreaming(&.{});
19+
var stdin_reader = fs.File.stdin().readerStreaming(&.{});
1920

2021
const cwd = fs.cwd();
2122

2223
for (args[1..]) |arg| {
2324
if (mem.eql(u8, arg, "-")) {
2425
catted_anything = true;
2526
_ = try stdout.sendFileAll(&stdin_reader, .unlimited);
27+
try stdout.flush();
2628
} else if (mem.startsWith(u8, arg, "-")) {
2729
return usage(exe);
2830
} else {
@@ -32,10 +34,12 @@ pub fn main() !void {
3234
catted_anything = true;
3335
var file_reader = file.reader(&.{});
3436
_ = try stdout.sendFileAll(&file_reader, .unlimited);
37+
try stdout.flush();
3538
}
3639
}
3740
if (!catted_anything) {
3841
_ = try stdout.sendFileAll(&stdin_reader, .unlimited);
42+
try stdout.flush();
3943
}
4044
}
4145

0 commit comments

Comments
 (0)