change define prefix and update docs (#7)

This commit is contained in:
Ștefan Talpalaru 2021-04-29 14:20:03 +02:00 committed by GitHub
parent c847fc3ec7
commit b9b61cfe4a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 1406 additions and 1389 deletions

View File

@ -1,4 +1,4 @@
name: nim-unittest2 CI
name: CI
on: [push, pull_request]
jobs:
@ -136,13 +136,13 @@ jobs:
- name: Build the Nim compiler
shell: bash
run: |
git clone -b ${{ matrix.branch }} --depth 1 git://github.com/nim-lang/nim nim/
curl -O -L -s -S https://raw.githubusercontent.com/status-im/nimbus-build-system/master/scripts/build_nim.sh
env MAKE="${MAKE_CMD} -j${ncpu}" ARCH_OVERRIDE=${PLATFORM} CC=gcc QUICK_AND_DIRTY_COMPILER=1 bash build_nim.sh nim csources dist/nimble NimBinaries
env MAKE="${MAKE_CMD} -j${ncpu}" ARCH_OVERRIDE=${PLATFORM} CC=gcc QUICK_AND_DIRTY_COMPILER=1 NIM_COMMIT=${{ matrix.branch }} bash build_nim.sh nim csources dist/nimble NimBinaries
echo '${{ github.workspace }}/nim/bin' >> $GITHUB_PATH
- name: Run tests
shell: bash
run: |
nim --version
nim --hints:off --verbosity:0 test

View File

@ -24,7 +24,7 @@ requires "unittest2"
## Usage
See [unittest2.html](https://status-im.github.io/nim-unittest2/unittest2.html) documentation generated by `nim doc unittest2.nim`.
See [unittest2.html](https://status-im.github.io/nim-unittest2/unittest2.html) documentation generated by `nim buildDocs`.
Create a file that contains your unit tests:

View File

@ -1,8 +1,24 @@
task test, "Run tests":
let
xmlFile = "test_results.xml"
commandStart = "nim c -r -f --threads:on --hints:off --verbosity:0 --skipParentCfg:on --skipUserCfg:on "
for f in listFiles("tests"):
if f.len > 4 and f[^4..^1] == ".nim":
let cmd = "nim c -r -f --threads:on --hints:off --verbosity:0 --skipParentCfg:on --skipUserCfg:on " & f
# This should generate an XML results file.
var cmd = commandStart & f & " --xml:" & xmlFile & " --console"
echo cmd
exec cmd
rmFile(f[0..^5].toExe())
doAssert fileExists xmlFile
rmFile xmlFile
# This should not, since we disable param processing.
cmd = commandStart & "-d:unittest2DisableParamFiltering " & f & " --xml:" & xmlFile
echo cmd
exec cmd
doAssert not fileExists xmlFile
rmFile f[0..^5].toExe
task buildDocs, "Build docs":
exec "nim doc --skipParentCfg:on --skipUserCfg:on --git.url:https://github.com/status-im/nim-unittest2 --git.commit:master --git.devel:master unittest2.nim"

891
nimdoc.out.css Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
{.push raises: [Defect].}
## :Authors: Zahary Karadjov, Stefan Talpalaru
## :Authors: Zahary Karadjov, Ștefan Talpalaru
##
## This module implements boilerplate to make unit testing easy.
##
@ -62,6 +62,16 @@
## # Run suites starting with 'bug #' and standalone tests starting with '#'
## nim c -r test 'bug #*::' '::#*'
##
## Command line arguments
## ======================
##
## --help Print short help and quit
## --xml:file Write JUnit-compatible XML report to `file`
## --console Write report to the console (default, when no other output is
## selected)
##
## Command line parsing can be disabled with `-d:unittest2DisableParamFiltering`.
##
## Running tests in parallel
## =========================
##
@ -118,16 +128,6 @@
##
## suiteTeardown:
## echo "suite teardown: run once after the tests"
##
## Command line arguments
## ======================
##
## --help Print short help and quit
## --xml:file Write JUnit-compatible XML report to `file`
## --console Write report to the console (default, when no other output is
## selected)
##
## Command line parsing can be disabled with `-d:nimtestDisableParamFiltering`.
import std/[locks, macros, sets, strutils, streams, times, monotimes]
@ -136,10 +136,10 @@ when declared(stdout):
const useTerminal = not defined(js)
# compile with `-d:nimtestDisableParamFiltering` to skip parsing test filters,
# compile with `-d:unittest2DisableParamFiltering` to skip parsing test filters,
# `--help` and other command line options - you can manually call
# `parseParameters` instead then.
const autoParseArgs = not defined(nimtestDisableParamFiltering)
const autoParseArgs = not defined(unittest2DisableParamFiltering)
when useTerminal:
import std/terminal
@ -252,7 +252,6 @@ var
formatters {.guard: formattersLock.}: seq[OutputFormatter]
testFiltersLock: Lock
testsFilters {.guard: testFiltersLock.}: HashSet[string]
disabledParamFiltering: bool
const
outputLevelDefault = PRINT_ALL
@ -953,6 +952,9 @@ macro expect*(exceptions: varargs[typed], body: untyped): untyped =
of 3: raise newException(IOError, "I can't do that Dave.")
else: assert 2 + 2 == 5
when (NimMajor, NimMinor, NimPatch) < (1, 4, 0):
type AssertionDefect = AssertionError
expect IOError, OSError, ValueError, AssertionDefect:
defectiveRobot()
@ -974,5 +976,5 @@ macro expect*(exceptions: varargs[typed], body: untyped): untyped =
result = getAst(expectBody(errorTypes, errorTypes.lineInfo, body))
proc disableParamFiltering* {.deprecated:
"Compile with -d:nimtestDisableParamFiltering instead".} =
"Compile with -d:unittest2DisableParamFiltering instead".} =
discard