summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorRay Imber <rayimber@gmail.com>2019-09-26 06:45:50 -0700
committerAndreas Rumpf <rumpf_a@web.de>2019-09-26 15:45:50 +0200
commit9dd297f613768bb170e05dcaf361015d9448c582 (patch)
tree9cc8c2e36d6b5dd39b30ed60ea04a327edc0d366
parent944fcc0e62bb22b9f5da79909dfbda4371de1fc6 (diff)
downloadNim-9dd297f613768bb170e05dcaf361015d9448c582.tar.gz
Locks modules should give a compile error when threads are not enabled. (#12231)
* Locks modules should give a compile error when threads are not enabled.

* fix the compile flags to make the tests pass, or ignore files where necessary.

* Fixed when statement to account for doc builds.
-rw-r--r--lib/core/locks.nim4
-rw-r--r--lib/core/rlocks.nim4
-rw-r--r--testament/testament.nim4
-rw-r--r--tests/stdlib/tsharedtable.nim1
4 files changed, 13 insertions, 0 deletions
diff --git a/lib/core/locks.nim b/lib/core/locks.nim
index 0143957ce..392c8aed4 100644
--- a/lib/core/locks.nim
+++ b/lib/core/locks.nim
@@ -9,6 +9,10 @@
 
 ## This module contains Nim's support for locks and condition vars.
 
+
+when not compileOption("threads") and not defined(nimdoc):
+  {.error: "Locks requires --threads:on option.".}
+
 const insideRLocksModule = false
 include "system/syslocks"
 
diff --git a/lib/core/rlocks.nim b/lib/core/rlocks.nim
index 4710d6cf1..34d7687f9 100644
--- a/lib/core/rlocks.nim
+++ b/lib/core/rlocks.nim
@@ -9,6 +9,10 @@
 
 ## This module contains Nim's support for reentrant locks.
 
+
+when not compileOption("threads") and not defined(nimdoc):
+  {.error: "Rlocks requires --threads:on option.".}
+
 const insideRLocksModule = true
 include "system/syslocks"
 
diff --git a/testament/testament.nim b/testament/testament.nim
index cf76cd971..da686a0c3 100644
--- a/testament/testament.nim
+++ b/testament/testament.nim
@@ -558,6 +558,10 @@ const disabledFilesDefault = @[
   "setimpl.nim",
   "hashcommon.nim",
 
+  # Requires compiling with '--threads:on`
+  "sharedlist.nim",
+  "sharedtables.nim",
+
   # Error: undeclared identifier: 'hasThreadSupport'
   "ioselectors_epoll.nim",
   "ioselectors_kqueue.nim",
diff --git a/tests/stdlib/tsharedtable.nim b/tests/stdlib/tsharedtable.nim
index 3269e7ee3..99d20e08a 100644
--- a/tests/stdlib/tsharedtable.nim
+++ b/tests/stdlib/tsharedtable.nim
@@ -1,4 +1,5 @@
 discard """
+cmd: "nim $target --threads:on $options $file"
 output: '''
 '''
 """