summary refs log tree commit diff stats
path: root/lib/pure/unittest.nim
diff options
context:
space:
mode:
Diffstat (limited to 'lib/pure/unittest.nim')
-rw-r--r--lib/pure/unittest.nim27
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