mirror of
https://github.com/status-im/nim-codex.git
synced 2025-01-12 03:44:07 +00:00
4f56f2af26
* add changes to use chronos v4 in compat mode * switch chronos to compat fix branch * use nimbus-build-system with configurable Nim repo * add missing imports * add missing await * bump compat * pin nim version in Makefile * add await instead of asyncSpawn to advertisement queue loop * bump DHT to v0.5.0 * allow error state of `onBatch` to propagate upwards in test code * pin Nim compiler commit to avoid fetching stale branch * make CI build against branch head instead of merge * fix handling of return values in testslotqueue
43 lines
1.1 KiB
Nim
43 lines
1.1 KiB
Nim
import pkg/chronos
|
|
|
|
# Allow multiple setups and teardowns in a test suite
|
|
template asyncmultisetup* =
|
|
var setups: seq[proc: Future[void].Raising([AsyncExceptionError]) {.gcsafe.}]
|
|
var teardowns: seq[
|
|
proc: Future[void].Raising([AsyncExceptionError]) {.gcsafe.}]
|
|
|
|
setup:
|
|
for setup in setups:
|
|
await setup()
|
|
|
|
teardown:
|
|
for teardown in teardowns:
|
|
await teardown()
|
|
|
|
template setup(setupBody) {.inject, used.} =
|
|
setups.add(proc {.async: (
|
|
handleException: true, raises: [AsyncExceptionError]).} = setupBody)
|
|
|
|
template teardown(teardownBody) {.inject, used.} =
|
|
teardowns.insert(proc {.async: (
|
|
handleException: true, raises: [AsyncExceptionError]).} = 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()
|
|
|
|
template setup(setupBody) {.inject, used.} =
|
|
let setupProc = proc = setupBody
|
|
setups.add(setupProc)
|
|
|
|
template teardown(teardownBody) {.inject, used.} =
|
|
teardowns.insert(proc = teardownBody)
|