summary refs log tree commit diff stats
path: root/tests/exception/t13115.nim
diff options
context:
space:
mode:
authorTimothee Cour <timothee.cour2@gmail.com>2020-12-11 01:35:05 -0800
committerGitHub <noreply@github.com>2020-12-11 10:35:05 +0100
commitbb1c962286922487c5243ca7304fd95fdd27ea53 (patch)
tree4fcfde898e9632f8fcd91b05a40c913ac9aa2aca /tests/exception/t13115.nim
parentbc84bd5d66e62c0e39ed781ddeb6a03e6d4163b2 (diff)
downloadNim-bb1c962286922487c5243ca7304fd95fdd27ea53.tar.gz
fix partially #13115 (now works for cpp; but still fails for js on openbsd) (#16167)
* fix partially #13115 properly (works for c,js,cpp,vm; still fails for js on openbsd)
* address comment: also test with -d:danger, -d:debug
Diffstat (limited to 'tests/exception/t13115.nim')
-rw-r--r--tests/exception/t13115.nim46
1 files changed, 36 insertions, 10 deletions
diff --git a/tests/exception/t13115.nim b/tests/exception/t13115.nim
index 53e078076..ee1daed26 100644
--- a/tests/exception/t13115.nim
+++ b/tests/exception/t13115.nim
@@ -1,12 +1,38 @@
-discard """
-  exitcode: 1
-  targets: "c"
-  matrix: "-d:debug; -d:release"
-  outputsub: ''' and works fine! [Exception]'''
-"""
+const msg = "This char is `" & '\0' & "` and works fine!"
 
-# bug #13115
-# xxx bug: doesn't yet work for cpp
+when defined nim_t13115:
+  # bug #13115
+  template fn =
+    raise newException(Exception, msg)
+  when defined nim_t13115_static:
+    static: fn()
+  fn()
+else:
+  import std/[osproc,strformat,os,strutils]
+  proc main =
+    const nim = getCurrentCompilerExe()
+    const file = currentSourcePath
+    for b in "c js cpp".split:
+      when defined(openbsd):
+        if b == "js":
+          # xxx bug: pending #13115
+          # remove special case once nodejs updated >= 12.16.2
+          # refs https://github.com/nim-lang/Nim/pull/16167#issuecomment-738270751
+          continue
 
-var msg = "This char is `" & '\0' & "` and works fine!"
-raise newException(Exception, msg)
+      # save CI time by avoiding mostly redundant combinations as far as this bug is concerned
+      var opts = case b
+        of "c": @["", "-d:nim_t13115_static", "-d:danger", "-d:debug"]
+        of "js": @["", "-d:nim_t13115_static"]
+        else: @[""]
+
+      for opt in opts:
+        let cmd = fmt"{nim} r -b:{b} -d:nim_t13115 {opt} --hints:off {file}"
+        let (outp, exitCode) = execCmdEx(cmd)
+        when defined windows:
+          # `\0` not preserved on windows
+          doAssert "` and works fine!" in outp, cmd & "\n" & msg
+        else:
+          doAssert msg in outp, cmd & "\n" & msg
+        doAssert exitCode == 1
+  main()