t13115.nim 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. const msg = "This char is `" & '\0' & "` and works fine!"
  2. when defined nim_t13115:
  3. # bug #13115
  4. template fn =
  5. raise newException(Exception, msg)
  6. when defined nim_t13115_static:
  7. static: fn()
  8. fn()
  9. else:
  10. import std/[osproc,strformat,os,strutils]
  11. proc main =
  12. const nim = getCurrentCompilerExe()
  13. const file = currentSourcePath
  14. for b in "c js cpp".split:
  15. when defined(openbsd):
  16. if b == "js":
  17. # xxx bug: pending #13115
  18. # remove special case once nodejs updated >= 12.16.2
  19. # refs https://github.com/nim-lang/Nim/pull/16167#issuecomment-738270751
  20. continue
  21. # save CI time by avoiding mostly redundant combinations as far as this bug is concerned
  22. var opts = case b
  23. of "c": @["", "-d:nim_t13115_static", "-d:danger", "-d:debug"]
  24. of "js": @["", "-d:nim_t13115_static"]
  25. else: @[""]
  26. for opt in opts:
  27. let cmd = fmt"{nim} r -b:{b} -d:nim_t13115 {opt} --hints:off {file}"
  28. let (outp, exitCode) = execCmdEx(cmd)
  29. when defined windows:
  30. # `\0` not preserved on windows
  31. doAssert "` and works fine!" in outp, cmd & "\n" & msg
  32. else:
  33. doAssert msg in outp, cmd & "\n" & msg
  34. doAssert exitCode == 1
  35. main()