From 642807de18670b53e152d2f2dd152a497f24da1b Mon Sep 17 00:00:00 2001 From: n5m <72841454+n5m@users.noreply.github.com> Date: Sun, 18 Oct 2020 16:57:13 +0000 Subject: [PATCH] add tests for #15584 (#15619) * add test for #15584 * Rename userlocks.nim to trlocks.nim * add bug comment * improve cmd * reference bugfix, not bug * add test that runs rlocks * disallow joining joining with other test cases (e.g., a test case that invokes `RLock.initRLock()`) may cause this test to compile, when the goal is to test if these lines can be compiled in isolation (cherry picked from commit 78cbb52fa01d6c73307fe276bdf7d4c34d7a556c) --- tests/stdlib/trlocks.nim | 14 ++++++++++++++ tests/stdlib/tuserlocks.nim | 13 +++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 tests/stdlib/trlocks.nim create mode 100644 tests/stdlib/tuserlocks.nim diff --git a/tests/stdlib/trlocks.nim b/tests/stdlib/trlocks.nim new file mode 100644 index 0000000000..135d9b0282 --- /dev/null +++ b/tests/stdlib/trlocks.nim @@ -0,0 +1,14 @@ +discard """ + action: "compile" + # Disallow joining to ensure it can compile in isolation. + # See #15584 + joinable: false + cmd: "nim $target --threads:on $options $file" +""" + +# bugfix #15584 + +import rlocks + +var r: RLock +r.initRLock() diff --git a/tests/stdlib/tuserlocks.nim b/tests/stdlib/tuserlocks.nim new file mode 100644 index 0000000000..f6eafa05d2 --- /dev/null +++ b/tests/stdlib/tuserlocks.nim @@ -0,0 +1,13 @@ +discard """ + cmd: "nim $target --threads:on $options $file" +""" + +import rlocks + +var r: RLock +r.initRLock() +doAssert r.tryAcquire() +doAssert r.tryAcquire() +r.release() +r.release() +r.deinitRLock()