summary refs log tree commit diff stats
path: root/lib/std
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-07-14 04:14:32 -0700
committerGitHub <noreply@github.com>2020-07-14 13:14:32 +0200
commite07d661d1600989c281a270d90563f1c60392b9d (patch)
treea708cc7b7bedf1473112907e2eb4a89d0ddd7003 /lib/std
parentffaf4797be4a8e8aec5ada9863ccdec66a066930 (diff)
downloadNim-e07d661d1600989c281a270d90563f1c60392b9d.tar.gz
fix #14475; unittest.require now works with `nim c`; require and check now works with -d:nodejs (#14676)
* fix #14475; make unittest work with -d:nodejs

* fixup

* fixup

* disable inim, delaunay which failed after unittest.require got fixed

* re-enable tests that have been fixed
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/exitprocs.nim22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/std/exitprocs.nim b/lib/std/exitprocs.nim
index b2811735c..c6537f7f8 100644
--- a/lib/std/exitprocs.nim
+++ b/lib/std/exitprocs.nim
@@ -63,3 +63,25 @@ proc addExitProc*(cl: proc() {.noconv.}) =
   withLock gFunsLock:
     fun()
     gFuns.add Fun(kind: kNoconv, fun2: cl)
+
+when not defined(nimscript):
+  proc getProgramResult*(): int =
+    when defined(js) and defined(nodejs):
+      asm """
+`result` = process.exitCode;
+"""
+    elif not defined(js):
+      result = programResult
+    else:
+      doAssert false
+
+  proc setProgramResult*(a: int) =
+    # pending https://github.com/nim-lang/Nim/issues/14674
+    when defined(js) and defined(nodejs):
+      asm """
+process.exitCode = `a`;
+"""
+    elif not defined(js):
+      programResult = a
+    else:
+      doAssert false