0 | module Test.Async.Spec.Runner
 1 |
 2 | import Data.Linear.Ref1
 3 | import Data.String
 4 | import IO.Async
 5 | import System
 6 | import Test.Async.Spec.Report
 7 | import Test.Async.Spec.TestEnv
 8 | import Test.Async.Spec.TestResult
 9 |
10 | %default total
11 |
12 | toBool : Maybe String -> Bool
13 | toBool Nothing  = False
14 | toBool (Just s) =
15 |   case toLower s of
16 |     "1"    => True
17 |     "yes"  => True
18 |     "true" => True
19 |     _      => False
20 |
21 | run : TestEnv => TestTree e -> Async e [] ()
22 | run (Leaf desc x)  = x >>= report desc
23 | run (Node name xs) = do
24 |   printName name 
25 |   incDepth
26 |   assert_total $ traverse_ run xs
27 |   decDepth
28 |
29 | export
30 | runTree : TestTree e -> Async e [] ()
31 | runTree tree = do
32 |   b  <- toBool <$> getEnv "SPEC_COLOR"
33 |   te <- mkEnv b
34 |   run @{te} tree
35 |   ts <- readref te.tests
36 |   fs <- readref te.failures
37 |   summary ts fs
38 |   when (fs > 0) exitFailure
39 |