Add support for unittest2
This commit is contained in:
parent
a7f3ae9428
commit
2e00a43236
|
@ -47,5 +47,12 @@ suite "test async proc":
|
|||
|
||||
```
|
||||
|
||||
Unittest2
|
||||
---------
|
||||
|
||||
The [unittest2][3] package is supported. Make sure that you
|
||||
`import asynctest/unittest2` instead of the normal import.
|
||||
|
||||
[1]: https://nim-lang.org/docs/unittest.html
|
||||
[2]: https://github.com/nim-lang/nimble
|
||||
[3]: https://github.com/status-im/nim-unittest2
|
||||
|
|
|
@ -1,23 +1,3 @@
|
|||
import unittest
|
||||
export unittest except suite, test
|
||||
import ./asynctest/unittest
|
||||
|
||||
template suite*(name, body) =
|
||||
suite name:
|
||||
|
||||
template setup(setupBody) {.used.} =
|
||||
setup:
|
||||
let asyncproc = proc {.async.} = setupBody
|
||||
waitFor asyncproc()
|
||||
|
||||
template teardown(teardownBody) {.used.} =
|
||||
teardown:
|
||||
let asyncproc = proc {.async.} = teardownBody
|
||||
waitFor asyncproc()
|
||||
|
||||
let suiteproc = proc = body # Avoids GcUnsafe2 warnings with chronos
|
||||
suiteproc()
|
||||
|
||||
template test*(name, body) =
|
||||
test name:
|
||||
let asyncproc = proc {.async.} = body
|
||||
waitFor asyncproc()
|
||||
export unittest
|
||||
|
|
|
@ -4,3 +4,9 @@ description = "Test asynchronous code"
|
|||
license = "MIT"
|
||||
|
||||
requires "nim >= 1.2.0 & < 2.0.0"
|
||||
|
||||
task test, "Runs the test suite":
|
||||
for module in ["stdlib", "chronos", "unittest2"]:
|
||||
withDir "testmodules/" & module:
|
||||
exec "nimble install -d -y"
|
||||
exec "nimble test -y"
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
template suite*(name, body) =
|
||||
suite name:
|
||||
|
||||
template setup(setupBody) {.used.} =
|
||||
setup:
|
||||
let asyncproc = proc {.async.} = setupBody
|
||||
waitFor asyncproc()
|
||||
|
||||
template teardown(teardownBody) {.used.} =
|
||||
teardown:
|
||||
let asyncproc = proc {.async.} = teardownBody
|
||||
waitFor asyncproc()
|
||||
|
||||
let suiteproc = proc = body # Avoids GcUnsafe2 warnings with chronos
|
||||
suiteproc()
|
||||
|
||||
template test*(name, body) =
|
||||
test name:
|
||||
let asyncproc = proc {.async.} = body
|
||||
waitFor asyncproc()
|
|
@ -0,0 +1,4 @@
|
|||
import std/unittest
|
||||
export unittest except suite, test
|
||||
|
||||
include ./templates
|
|
@ -0,0 +1,4 @@
|
|||
import pkg/unittest2
|
||||
export unittest2 except suite, test
|
||||
|
||||
include ./templates
|
|
@ -0,0 +1 @@
|
|||
--path:"../.."
|
|
@ -0,0 +1,4 @@
|
|||
import pkg/asynctest
|
||||
import pkg/chronos
|
||||
|
||||
include ../stdlib/testbody
|
|
@ -0,0 +1,9 @@
|
|||
version = "0.1.0"
|
||||
author = "Asynctest Authors"
|
||||
description = "Asynctest tests for std/unittest and pkg/chronos"
|
||||
license = "MIT"
|
||||
|
||||
requires "chronos"
|
||||
|
||||
task test, "Runs the test suite":
|
||||
exec "nim c -f -r test.nim"
|
|
@ -0,0 +1 @@
|
|||
--path:"../.."
|
|
@ -0,0 +1,4 @@
|
|||
import std/asyncdispatch
|
||||
import pkg/asynctest
|
||||
|
||||
include ./testbody
|
|
@ -0,0 +1,7 @@
|
|||
version = "0.1.0"
|
||||
author = "Asynctest Authors"
|
||||
description = "Asynctest tests for std/unittest and std/asyncdispatch"
|
||||
license = "MIT"
|
||||
|
||||
task test, "Runs the test suite":
|
||||
exec "nim c -f -r test.nim"
|
|
@ -1,6 +1,3 @@
|
|||
import std/asyncdispatch
|
||||
import pkg/asynctest
|
||||
|
||||
proc someAsyncProc {.async.} =
|
||||
# perform some async operations using await
|
||||
discard
|
|
@ -0,0 +1 @@
|
|||
--path:"../.."
|
|
@ -0,0 +1,4 @@
|
|||
import pkg/asynctest/unittest2
|
||||
import pkg/chronos
|
||||
|
||||
include ../stdlib/testbody
|
|
@ -0,0 +1,10 @@
|
|||
version = "0.1.0"
|
||||
author = "Asynctest Authors"
|
||||
description = "Asynctest tests for pkg/unittest2 and pkg/chronos"
|
||||
license = "MIT"
|
||||
|
||||
requires "unittest2"
|
||||
requires "chronos"
|
||||
|
||||
task test, "Runs the test suite":
|
||||
exec "nim c -f -r test.nim"
|
|
@ -1 +0,0 @@
|
|||
--path:".."
|
Loading…
Reference in New Issue