authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-22 20:55:47-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-23 22:15:12-08:00
log6ece10f63d91cfa16d8388f8d696368537c1662e
tree15aace22978455db73c29736606165589a312ee3
parente9da2783ce3c65d8e8e8533b7c70ec5a867f830a

update test-link to new std.Io API


9 files changed, 29 insertions(+), 10 deletions(-)

test/link/bss/main.zig+1-1
...@@ -4,7 +4,7 @@ const std = @import("std");...@@ -4,7 +4,7 @@ const std = @import("std");
4var buffer: [0x1000000]u64 = [1]u64{0} ** 0x1000000;4var buffer: [0x1000000]u64 = [1]u64{0} ** 0x1000000;
55
6pub fn main() anyerror!void {6pub fn main() anyerror!void {
7 var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});7 var stdout_writer = std.Io.File.stdout().writerStreaming(std.Options.debug_io, &.{});
88
9 buffer[0x10] = 1;9 buffer[0x10] = 1;
1010
test/link/elf.zig+2-2
...@@ -1323,7 +1323,7 @@ fn testGcSectionsZig(b: *Build, opts: Options) *Step {...@@ -1323,7 +1323,7 @@ fn testGcSectionsZig(b: *Build, opts: Options) *Step {
1323 \\extern var live_var2: i32;1323 \\extern var live_var2: i32;
1324 \\extern fn live_fn2() void;1324 \\extern fn live_fn2() void;
1325 \\pub fn main() void {1325 \\pub fn main() void {
1326 \\ var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});1326 \\ var stdout_writer = std.Io.File.stdout().writerStreaming(std.Options.debug_io, &.{});
1327 \\ stdout_writer.interface.print("{d} {d}\n", .{ live_var1, live_var2 }) catch @panic("fail");1327 \\ stdout_writer.interface.print("{d} {d}\n", .{ live_var1, live_var2 }) catch @panic("fail");
1328 \\ live_fn2();1328 \\ live_fn2();
1329 \\}1329 \\}
...@@ -1365,7 +1365,7 @@ fn testGcSectionsZig(b: *Build, opts: Options) *Step {...@@ -1365,7 +1365,7 @@ fn testGcSectionsZig(b: *Build, opts: Options) *Step {
1365 \\extern var live_var2: i32;1365 \\extern var live_var2: i32;
1366 \\extern fn live_fn2() void;1366 \\extern fn live_fn2() void;
1367 \\pub fn main() void {1367 \\pub fn main() void {
1368 \\ var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});1368 \\ var stdout_writer = std.Io.File.stdout().writerStreaming(std.Options.debug_io, &.{});
1369 \\ stdout_writer.interface.print("{d} {d}\n", .{ live_var1, live_var2 }) catch @panic("fail");1369 \\ stdout_writer.interface.print("{d} {d}\n", .{ live_var1, live_var2 }) catch @panic("fail");
1370 \\ live_fn2();1370 \\ live_fn2();
1371 \\}1371 \\}
test/link/macho.zig+2-2
...@@ -716,7 +716,7 @@ fn testHelloZig(b: *Build, opts: Options) *Step {...@@ -716,7 +716,7 @@ fn testHelloZig(b: *Build, opts: Options) *Step {
716 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =716 const exe = addExecutable(b, opts, .{ .name = "main", .zig_source_bytes =
717 \\const std = @import("std");717 \\const std = @import("std");
718 \\pub fn main() void {718 \\pub fn main() void {
719 \\ std.Io.File.stdout().writeAll("Hello world!\n") catch @panic("fail");719 \\ std.Io.File.stdout().writeStreamingAll(std.Options.debug_io, "Hello world!\n") catch @panic("fail");
720 \\}720 \\}
721 });721 });
722722
...@@ -2372,7 +2372,7 @@ fn testTlsZig(b: *Build, opts: Options) *Step {...@@ -2372,7 +2372,7 @@ fn testTlsZig(b: *Build, opts: Options) *Step {
2372 \\threadlocal var x: i32 = 0;2372 \\threadlocal var x: i32 = 0;
2373 \\threadlocal var y: i32 = -1;2373 \\threadlocal var y: i32 = -1;
2374 \\pub fn main() void {2374 \\pub fn main() void {
2375 \\ var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});2375 \\ var stdout_writer = std.Io.File.stdout().writerStreaming(std.Options.debug_io, &.{});
2376 \\ stdout_writer.interface.print("{d} {d}\n", .{x, y}) catch unreachable;2376 \\ stdout_writer.interface.print("{d} {d}\n", .{x, y}) catch unreachable;
2377 \\ x -= 1;2377 \\ x -= 1;
2378 \\ y += 1;2378 \\ y += 1;
test/link/wasm/extern/main.zig+1-1
...@@ -3,6 +3,6 @@ const std = @import("std");...@@ -3,6 +3,6 @@ const std = @import("std");
3extern const foo: u32;3extern const foo: u32;
44
5pub fn main() void {5pub fn main() void {
6 var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});6 var stdout_writer = std.Io.File.stdout().writerStreaming(std.Options.debug_io, &.{});
7 stdout_writer.interface.print("Result: {d}", .{foo}) catch {};7 stdout_writer.interface.print("Result: {d}", .{foo}) catch {};
8}8}
test/standalone/simple/guess_number/main.zig+11-1
...@@ -1,8 +1,18 @@...@@ -1,8 +1,18 @@
1const builtin = @import("builtin");1const builtin = @import("builtin");
2const std = @import("std");2const std = @import("std");
33
4// See https://github.com/ziglang/zig/issues/24510
5// for the plan to simplify this code.
4pub fn main() !void {6pub fn main() !void {
5 var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});7 var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
8 defer _ = debug_allocator.deinit();
9 const gpa = debug_allocator.allocator();
10
11 var threaded: std.Io.Threaded = .init(gpa, .{});
12 defer threaded.deinit();
13 const io = threaded.io();
14
15 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
6 const out = &stdout_writer.interface;16 const out = &stdout_writer.interface;
7 const stdin: std.Io.File = .stdin();17 const stdin: std.Io.File = .stdin();
818
test/standalone/simple/hello_world/hello.zig+2
...@@ -1,5 +1,7 @@...@@ -1,5 +1,7 @@
1const std = @import("std");1const std = @import("std");
22
3// See https://github.com/ziglang/zig/issues/24510
4// for the plan to simplify this code.
3pub fn main() !void {5pub fn main() !void {
4 var debug_allocator: std.heap.DebugAllocator(.{}) = .init;6 var debug_allocator: std.heap.DebugAllocator(.{}) = .init;
5 defer _ = debug_allocator.deinit();7 defer _ = debug_allocator.deinit();
test/standalone/windows_bat_args/echo-args.zig+3-1
...@@ -5,7 +5,9 @@ pub fn main() !void {...@@ -5,7 +5,9 @@ pub fn main() !void {
5 defer arena_state.deinit();5 defer arena_state.deinit();
6 const arena = arena_state.allocator();6 const arena = arena_state.allocator();
77
8 var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});8 const io = std.Options.debug_io;
9
10 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
9 const stdout = &stdout_writer.interface;11 const stdout = &stdout_writer.interface;
10 var args = try std.process.argsAlloc(arena);12 var args = try std.process.argsAlloc(arena);
11 for (args[1..], 1..) |arg, i| {13 for (args[1..], 1..) |arg, i| {
test/standalone/windows_paths/relative.zig+5-1
...@@ -10,10 +10,14 @@ pub fn main() !void {...@@ -10,10 +10,14 @@ pub fn main() !void {
1010
11 if (args.len < 3) return error.MissingArgs;11 if (args.len < 3) return error.MissingArgs;
1212
13 var threaded: std.Io.Threaded = .init(allocator, .{});
14 defer threaded.deinit();
15 const io = threaded.io();
16
13 const relative = try std.fs.path.relative(allocator, args[1], args[2]);17 const relative = try std.fs.path.relative(allocator, args[1], args[2]);
14 defer allocator.free(relative);18 defer allocator.free(relative);
1519
16 var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});20 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
17 const stdout = &stdout_writer.interface;21 const stdout = &stdout_writer.interface;
18 try stdout.writeAll(relative);22 try stdout.writeAll(relative);
19}23}
test/standalone/windows_spawn/hello.zig+2-1
...@@ -1,7 +1,8 @@...@@ -1,7 +1,8 @@
1const std = @import("std");1const std = @import("std");
22
3pub fn main() !void {3pub fn main() !void {
4 var stdout_writer = std.Io.File.stdout().writerStreaming(&.{});4 const io = std.Options.debug_io;
5 var stdout_writer = std.Io.File.stdout().writerStreaming(io, &.{});
5 const stdout = &stdout_writer.interface;6 const stdout = &stdout_writer.interface;
6 try stdout.writeAll("hello from exe\n");7 try stdout.writeAll("hello from exe\n");
7}8}