aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Thread.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2025-12-18 22:03:10 -0800
committerAndrew Kelley <andrew@ziglang.org>2025-12-23 22:15:10 -0800
commit7ce5ee2e92bf1bf1f39ccc08df19f9a1044e9f2c (patch)
tree6d1d5f066c72636fc1da74fddce4e44e211b431f /lib/std/Thread.zig
parent21d0264c61ac29724b98187aa87d192f97b52425 (diff)
downloadzig-7ce5ee2e92bf1bf1f39ccc08df19f9a1044e9f2c.tar.gz
zig-7ce5ee2e92bf1bf1f39ccc08df19f9a1044e9f2c.zip
std: update remaining unit tests for std.Io API changes
Diffstat (limited to 'lib/std/Thread.zig')
-rw-r--r--lib/std/Thread.zig18
1 files changed, 10 insertions, 8 deletions
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig
index 8453bc4c81..fbce1cd000 100644
--- a/lib/std/Thread.zig
+++ b/lib/std/Thread.zig
@@ -211,7 +211,7 @@ pub fn setName(self: Thread, io: Io, name: []const u8) SetNameError!void {
const file = try Io.Dir.cwd().openFile(io, path, .{ .mode = .write_only });
defer file.close(io);
- try file.writeAll(name);
+ try file.writeStreamingAll(io, name);
return;
},
.windows => {
@@ -1676,14 +1676,14 @@ const LinuxThreadImpl = struct {
}
};
-fn testThreadName(thread: *Thread) !void {
+fn testThreadName(io: Io, thread: *Thread) !void {
const testCases = &[_][]const u8{
"mythread",
"b" ** max_name_len,
};
inline for (testCases) |tc| {
- try thread.setName(tc);
+ try thread.setName(io, tc);
var name_buffer: [max_name_len:0]u8 = undefined;
@@ -1698,6 +1698,8 @@ fn testThreadName(thread: *Thread) !void {
test "setName, getName" {
if (builtin.single_threaded) return error.SkipZigTest;
+ const io = testing.io;
+
const Context = struct {
start_wait_event: ResetEvent = .unset,
test_done_event: ResetEvent = .unset,
@@ -1711,11 +1713,11 @@ test "setName, getName" {
ctx.start_wait_event.wait();
switch (native_os) {
- .windows => testThreadName(&ctx.thread) catch |err| switch (err) {
+ .windows => testThreadName(io, &ctx.thread) catch |err| switch (err) {
error.Unsupported => return error.SkipZigTest,
else => return err,
},
- else => try testThreadName(&ctx.thread),
+ else => try testThreadName(io, &ctx.thread),
}
// Signal our test is done
@@ -1735,14 +1737,14 @@ test "setName, getName" {
switch (native_os) {
.driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => {
- const res = thread.setName("foobar");
+ const res = thread.setName(io, "foobar");
try std.testing.expectError(error.Unsupported, res);
},
- .windows => testThreadName(&thread) catch |err| switch (err) {
+ .windows => testThreadName(io, &thread) catch |err| switch (err) {
error.Unsupported => return error.SkipZigTest,
else => return err,
},
- else => try testThreadName(&thread),
+ else => try testThreadName(io, &thread),
}
context.thread_done_event.set();