Skip to content

Commit

Permalink
feat: introduce some changes/additions from test/use-cases branch
Browse files Browse the repository at this point in the history
But without introducing the use cases tests themselves nor their dependencies
in vendor.
  • Loading branch information
michaelsbradleyjr committed Mar 12, 2021
1 parent b2442ec commit a87f3f8
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 7 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
run: |
make -j${NPROC} NIMFLAGS="--parallelBuild:${NPROC}" V=1 test
- name: Build and run channel_helgrind
- name: Build and run helgrind tasks
if: matrix.platform.os == 'ubuntu'
run: |
./env.sh nimble channel_helgrind
./env.sh nimble achannels_helgrind
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ BUILD_SYSTEM_DIR := vendor/nimbus-build-system
.PHONY: \
all \
clean \
clean-build-dirs \
deps \
test \
update
Expand Down
4 changes: 2 additions & 2 deletions task_runner.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
# Licensed under either of
# Apache License, version 2.0, (LICENSE-APACHEv2)
# MIT license (LICENSE-MIT)
import ./task_runner/achannels
import ./task_runner/achannels, ./task_runner/sys

export achannels
export achannels, sys
5 changes: 3 additions & 2 deletions task_runner.nimble
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ proc buildAndRunTest(name: string,
" --debugger:native" &
" --define:chronicles_line_numbers" &
" --define:debug" &
" --define:ssl" &
" --linetrace:on" &
" --nimcache:nimcache/test/" & name &
" --out:" & outDir & name &
Expand All @@ -43,13 +44,13 @@ proc buildAndRunTest(name: string,
task tests, "Run all tests":
buildAndRunTest "test_all"

task channel_helgrind, "Run channel implementation through helgrind to detect threading or lock errors":
task achannels_helgrind, "Run channel implementation through helgrind to detect threading or lock errors":
rmDir "test/build/"
mkDir "test/build/"
var commands = [
"nim c" &
" --define:useMalloc" &
" --nimcache:nimcache/test/channel_helgrind" &
" --nimcache:nimcache/test/achannels_helgrind" &
" --out:test/build/test_achannels" &
" --threads:on" &
" --tlsEmulation:off" &
Expand Down
12 changes: 12 additions & 0 deletions task_runner/sys.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
type
ThreadSafeString* = distinct cstring

proc safe*(input: string): ThreadSafeString =
var res = cast[cstring](allocShared(input.len + 1))
copyMem(res, input.cstring, input.len)
res[input.len] = '\0'
res.ThreadSafeString

proc `$`*(input: ThreadSafeString): string =
result = $(input.cstring)
deallocShared input.cstring
12 changes: 12 additions & 0 deletions test/test_helpers.nim
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import chronos, unittest

template asyncTest*(name, body: untyped) =
test name:
proc scenario {.async.} = body
waitFor scenario()

template procSuite*(name, body: untyped) =
proc suitePayload =
suite name:
body
suitePayload()
2 changes: 1 addition & 1 deletion vendor/nimbus-build-system

0 comments on commit a87f3f8

Please sign in to comment.