From 9dd297f613768bb170e05dcaf361015d9448c582 Mon Sep 17 00:00:00 2001 From: Ray Imber Date: Thu, 26 Sep 2019 06:45:50 -0700 Subject: 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. --- lib/core/locks.nim | 4 ++++ lib/core/rlocks.nim | 4 ++++ testament/testament.nim | 4 ++++ tests/stdlib/tsharedtable.nim | 1 + 4 files changed, 13 insertions(+) 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: ''' ''' """ -- cgit 1.4.1-2-gfad0