Commit 895e6eabc2

Shritesh Bhattarai <shritesh@shritesh.com>
2019-04-06 00:12:46
Fix getCurrentId test for pthreads (#2197)
* Fix getCurrentId test for pthreads
1 parent d72239d
Changed files (1)
std
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);
+            },
+        }
     }
 }