mirror of
https://github.com/logos-storage/asynctest.git
synced 2026-01-02 13:03:07 +00:00
Asynchronous testing in Nim
This commit is contained in:
commit
bb5bc92605
5
.editorconfig
Normal file
5
.editorconfig
Normal file
@ -0,0 +1,5 @@
|
||||
[*]
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
indent_size = 2
|
||||
trim_trailing_whitespace = true
|
||||
15
.github/workflows/test.yml
vendored
Normal file
15
.github/workflows/test.yml
vendored
Normal file
@ -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
|
||||
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
*
|
||||
!*/
|
||||
!*.*
|
||||
1
.tool-versions
Normal file
1
.tool-versions
Normal file
@ -0,0 +1 @@
|
||||
nim 1.4.2
|
||||
14
asynctest.nim
Normal file
14
asynctest.nim
Normal file
@ -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()
|
||||
6
asynctest.nimble
Normal file
6
asynctest.nimble
Normal file
@ -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"
|
||||
1
tests/nim.cfg
Normal file
1
tests/nim.cfg
Normal file
@ -0,0 +1 @@
|
||||
--path:".."
|
||||
16
tests/testAsyncTest.nim
Normal file
16
tests/testAsyncTest.nim
Normal file
@ -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…
x
Reference in New Issue
Block a user