Asynchronous testing in Nim
This commit is contained in:
commit
bb5bc92605
|
@ -0,0 +1,5 @@
|
|||
[*]
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
|
@ -0,0 +1,15 @@
|
|||
name: CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macOS-latest, windows-latest]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: iffy/install-nim@v3
|
||||
- name: Test
|
||||
run: nimble test -y
|
|
@ -0,0 +1,3 @@
|
|||
*
|
||||
!*/
|
||||
!*.*
|
|
@ -0,0 +1 @@
|
|||
nim 1.4.2
|
|
@ -0,0 +1,14 @@
|
|||
template asynctest*(name, body) =
|
||||
test name:
|
||||
let asyncproc = proc {.async.} = body
|
||||
waitFor asyncproc()
|
||||
|
||||
template asyncsetup*(body) =
|
||||
setup:
|
||||
let asyncproc = proc {.async.} = body
|
||||
waitFor asyncproc()
|
||||
|
||||
template asyncteardown*(body) =
|
||||
teardown:
|
||||
let asyncproc = proc {.async.} = body
|
||||
waitFor asyncproc()
|
|
@ -0,0 +1,6 @@
|
|||
version = "0.1.0"
|
||||
author = "asynctest Authors"
|
||||
description = "Test asynchronous code"
|
||||
license = "MIT"
|
||||
|
||||
requires "nim >= 1.2.0 & < 2.0.0"
|
|
@ -0,0 +1 @@
|
|||
--path:".."
|
|
@ -0,0 +1,16 @@
|
|||
import std/unittest
|
||||
import std/asyncdispatch
|
||||
import pkg/asynctest
|
||||
|
||||
suite "async tests":
|
||||
|
||||
proc asyncproc {.async.} = discard
|
||||
|
||||
asyncsetup: # allows await in setup
|
||||
await asyncproc()
|
||||
|
||||
asyncteardown: # allows await in teardown
|
||||
await asyncproc()
|
||||
|
||||
asynctest "allows await in tests":
|
||||
await asyncproc()
|
Loading…
Reference in New Issue