Mark Spanbroek 17fb5ab4b7 Explicitly import either asyncdispatch or chronos version
Reorganizes the code into separate versions for asyncdispatch and
chronos so that we no longer have to rely on hard-to-maintain code
that implicitly works with both asyncdispatch and chronos.

This is a backwards incompatible change.
2023-12-21 10:01:58 +01:00

35 lines
815 B
Nim

template tryImport(module) = import module
when compiles tryImport std/exitprocs:
import std/exitprocs
else:
template getProgramResult: auto = programResult
template setProgramResult(value) = programResult = value
template silent(body) =
let exitcode = getProgramResult()
resetOutputFormatters()
addOutputFormatter(OutputFormatter())
body
resetOutputFormatters()
addOutputFormatter(defaultConsoleFormatter())
setProgramResult(exitcode)
suite "reports unhandled exception when teardown handles exceptions too":
silent:
proc someAsyncProc {.async.} = discard
teardown:
try:
await someAsyncProc()
except CatchableError:
discard
test "should fail, but not crash":
if true:
raise newException(ValueError, "This exception is expected")