diff options
author | Rostyslav Dzinko <rostislav.dzinko@gmail.com> | 2016-06-03 12:02:38 +0300 |
---|---|---|
committer | Rostyslav Dzinko <rostislav.dzinko@gmail.com> | 2016-06-03 12:02:38 +0300 |
commit | d91b0cbc2b2484e2883dd61209b9ec5426be647d (patch) | |
tree | 2a498c3201b70dda5683904dc7a5b793979a3aab | |
parent | cc80eac84b2f778a6a34d9c088e9e88c3a62c0bb (diff) | |
download | Nim-d91b0cbc2b2484e2883dd61209b9ec5426be647d.tar.gz |
Implemented SKIPPED test status
-rw-r--r-- | lib/pure/unittest.nim | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/pure/unittest.nim b/lib/pure/unittest.nim index b83ec44ca..e8a23f27e 100644 --- a/lib/pure/unittest.nim +++ b/lib/pure/unittest.nim @@ -41,7 +41,11 @@ when not defined(ECMAScript): import terminal type - TestStatus* = enum OK, FAILED ## The status of a test when it is done. + TestStatus* = enum ## The status of a test when it is done. + OK, + FAILED, + SKIPPED + OutputLevel* = enum ## The output verbosity of the tests. PRINT_ALL, ## Print as much as possible. PRINT_FAILURES, ## Print only the failed tests. @@ -120,7 +124,11 @@ proc testDone(name: string, s: TestStatus) = template rawPrint() = echo("[", $s, "] ", name) when not defined(ECMAScript): if colorOutput and not defined(ECMAScript): - var color = (if s == OK: fgGreen else: fgRed) + var color = case s + of OK: fgGreen + of FAILED: fgRed + of SKIPPED: fgYellow + else: fgWhite styledEcho styleBright, color, "[", $s, "] ", fgWhite, name else: rawPrint() @@ -203,6 +211,21 @@ template fail* = checkpoints = @[] +template skip* = + ## Makes test to be skipped. Should be used directly + ## in case when it is not possible to perform test + ## for reasons depending on outer environment, + ## or certain application logic conditions or configurations. + ## + ## .. code-block:: nim + ## + ## if not isGLConextCreated(): + ## skip() + bind checkpoints + + testStatusIMPL = SKIPPED + checkpoints = @[] + macro check*(conditions: stmt): stmt {.immediate.} = ## Verify if a statement or a list of statements is true. ## A helpful error message and set checkpoints are printed out on |