mirror of
https://github.com/logos-storage/asynctest.git
synced 2026-01-04 05:53:10 +00:00
Fix for unittest2 > 0.0.9
Define our templates inside a new scope, to make sure that they don't clash with the unittest2 templates.
This commit is contained in:
parent
9f31323a5f
commit
bb07f702fb
@ -20,31 +20,31 @@ template launderExceptions(body: typed) =
|
|||||||
template suite*(name, body) =
|
template suite*(name, body) =
|
||||||
|
|
||||||
suite name:
|
suite name:
|
||||||
|
|
||||||
## Runs before all tests in the suite
|
|
||||||
template setupAll(setupAllBody) {.used.} =
|
|
||||||
let b = proc {.async.} = launderExceptions: setupAllBody
|
|
||||||
waitFor b()
|
|
||||||
|
|
||||||
## Runs after all tests in the suite
|
|
||||||
template teardownAll(teardownAllBody) {.used.} =
|
|
||||||
template teardownAllIMPL: untyped {.inject.} =
|
|
||||||
let a = proc {.async.} = launderExceptions: teardownAllBody
|
|
||||||
waitFor a()
|
|
||||||
|
|
||||||
template setup(setupBody) {.used.} =
|
|
||||||
setup:
|
|
||||||
let asyncproc = proc {.async.} = launderExceptions: setupBody
|
|
||||||
waitFor asyncproc()
|
|
||||||
|
|
||||||
template teardown(teardownBody) {.used.} =
|
|
||||||
teardown:
|
|
||||||
let exception = getCurrentException()
|
|
||||||
let asyncproc = proc {.async.} = launderExceptions: teardownBody
|
|
||||||
waitFor asyncproc()
|
|
||||||
setCurrentException(exception)
|
|
||||||
|
|
||||||
let suiteproc = proc = # Avoids GcUnsafe2 warnings with chronos
|
let suiteproc = proc = # Avoids GcUnsafe2 warnings with chronos
|
||||||
|
|
||||||
|
## Runs before all tests in the suite
|
||||||
|
template setupAll(setupAllBody) {.used.} =
|
||||||
|
let b = proc {.async.} = launderExceptions: setupAllBody
|
||||||
|
waitFor b()
|
||||||
|
|
||||||
|
## Runs after all tests in the suite
|
||||||
|
template teardownAll(teardownAllBody) {.used.} =
|
||||||
|
template teardownAllIMPL: untyped {.inject.} =
|
||||||
|
let a = proc {.async.} = launderExceptions: teardownAllBody
|
||||||
|
waitFor a()
|
||||||
|
|
||||||
|
template setup(setupBody) {.used.} =
|
||||||
|
setup:
|
||||||
|
let asyncproc = proc {.async.} = launderExceptions: setupBody
|
||||||
|
waitFor asyncproc()
|
||||||
|
|
||||||
|
template teardown(teardownBody) {.used.} =
|
||||||
|
teardown:
|
||||||
|
let exception = getCurrentException()
|
||||||
|
let asyncproc = proc {.async.} = launderExceptions: teardownBody
|
||||||
|
waitFor asyncproc()
|
||||||
|
setCurrentException(exception)
|
||||||
|
|
||||||
body
|
body
|
||||||
|
|
||||||
when declared(teardownAllIMPL):
|
when declared(teardownAllIMPL):
|
||||||
|
|||||||
@ -3,7 +3,7 @@ author = "Asynctest Authors"
|
|||||||
description = "Asynctest tests for pkg/unittest2 and pkg/chronos"
|
description = "Asynctest tests for pkg/unittest2 and pkg/chronos"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
||||||
requires "unittest2 <= 0.0.9"
|
requires "unittest2"
|
||||||
requires "chronos"
|
requires "chronos"
|
||||||
|
|
||||||
task test, "Runs the test suite":
|
task test, "Runs the test suite":
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user