From 895e6eabc2fb294719dc39d6ad05e79086470b3d Mon Sep 17 00:00:00 2001 From: Shritesh Bhattarai Date: Fri, 5 Apr 2019 17:12:46 -0500 Subject: [PATCH] Fix getCurrentId test for pthreads (#2197) * Fix getCurrentId test for pthreads --- std/os/test.zig | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/std/os/test.zig b/std/os/test.zig index 0f34e5279c..0ee6fc1f26 100644 --- a/std/os/test.zig +++ b/std/os/test.zig @@ -46,13 +46,17 @@ test "std.os.Thread.getCurrentId" { const thread = try os.spawnThread(&thread_current_id, testThreadIdFn); const thread_id = thread.handle(); thread.wait(); - switch (builtin.os) { - builtin.Os.windows => expect(os.Thread.getCurrentId() != thread_current_id), - else => { - // If the thread completes very quickly, then thread_id can be 0. See the - // documentation comments for `std.os.Thread.handle`. - expect(thread_id == 0 or thread_current_id == thread_id); - }, + if (os.Thread.use_pthreads) { + expect(thread_current_id == thread_id); + } else { + switch (builtin.os) { + builtin.Os.windows => expect(os.Thread.getCurrentId() != thread_current_id), + else => { + // If the thread completes very quickly, then thread_id can be 0. See the + // documentation comments for `std.os.Thread.handle`. + expect(thread_id == 0 or thread_current_id == thread_id); + }, + } } }