2023-06-22 18:01:21 +00:00
|
|
|
import pkg/chronos
|
|
|
|
|
|
|
|
# Allow multiple setups and teardowns in a test suite
|
|
|
|
template asyncmultisetup* =
|
|
|
|
var setups: seq[proc: Future[void] {.gcsafe.}]
|
|
|
|
var teardowns: seq[proc: Future[void] {.gcsafe.}]
|
|
|
|
|
|
|
|
setup:
|
|
|
|
for setup in setups:
|
|
|
|
await setup()
|
|
|
|
|
|
|
|
teardown:
|
|
|
|
for teardown in teardowns:
|
|
|
|
await teardown()
|
|
|
|
|
2023-09-13 14:17:56 +00:00
|
|
|
template setup(setupBody) {.inject, used.} =
|
2023-06-22 18:01:21 +00:00
|
|
|
setups.add(proc {.async.} = setupBody)
|
|
|
|
|
2023-09-13 14:17:56 +00:00
|
|
|
template teardown(teardownBody) {.inject, used.} =
|
2023-06-22 18:01:21 +00:00
|
|
|
teardowns.insert(proc {.async.} = teardownBody)
|
|
|
|
|
|
|
|
template multisetup* =
|
|
|
|
var setups: seq[proc() {.gcsafe.}]
|
|
|
|
var teardowns: seq[proc() {.gcsafe.}]
|
|
|
|
|
|
|
|
setup:
|
|
|
|
for setup in setups:
|
|
|
|
setup()
|
|
|
|
|
|
|
|
teardown:
|
|
|
|
for teardown in teardowns:
|
|
|
|
teardown()
|
|
|
|
|
2023-09-13 14:17:56 +00:00
|
|
|
template setup(setupBody) {.inject, used.} =
|
2023-06-22 18:01:21 +00:00
|
|
|
setups.add(proc = setupBody)
|
|
|
|
|
2023-09-13 14:17:56 +00:00
|
|
|
template teardown(teardownBody) {.inject, used.} =
|
2023-06-22 18:01:21 +00:00
|
|
|
teardowns.insert(proc = teardownBody)
|