File tree Expand file tree Collapse file tree 3 files changed +13
-9
lines changed
src/Test/Hspec/Formatters Expand file tree Collapse file tree 3 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -8,15 +8,19 @@ Specify `codewars` formatter:
88
99``` haskell
1010-- test/Main.hs
11- module Main where
11+ module Main ( main ) where
1212
1313import Test.Hspec.Runner
14- import Test.Hspec.Formatters.Codewars (codewars )
14+ import Test.Hspec.Formatters.Codewars (newFormatter )
15+ import Test.Hspec.Core.Formatters.V2 (formatterToFormat )
1516
1617import qualified Spec
1718
1819main :: IO ()
19- main = hspecWith defaultConfig {configFormatter = Just codewars} Spec. spec
20+ main = do
21+ codewars <- newFormatter
22+ runSpec Spec. spec defaultConfig {configFormat = Just $ formatterToFormat codewars}
23+ >>= evaluateSummary
2024```
2125
2226``` haskell
Original file line number Diff line number Diff line change 11{-# LANGUAGE OverloadedStrings #-}
22
3- module Test.Hspec.Formatters.Codewars (codewars , escapeLF ) where
3+ module Test.Hspec.Formatters.Codewars (newFormatter , escapeLF ) where
44
55import Data.Text (pack , replace , unpack )
66import Text.Printf (printf )
@@ -23,8 +23,8 @@ import Test.Hspec.Core.Formatters.V2 (
2323getName :: Path -> String
2424getName (_, req) = escapeLF req
2525
26- codewars :: IO Formatter
27- codewars = do
26+ newFormatter :: IO Formatter
27+ newFormatter = do
2828 times <- newIORef ([ ]:: [Seconds ])
2929 pure $ silent
3030 {
Original file line number Diff line number Diff line change @@ -3,16 +3,16 @@ module Main (main) where
33import System.Exit
44
55import Test.Hspec.Runner
6- import Test.Hspec.Formatters.Codewars (codewars , escapeLF )
6+ import Test.Hspec.Formatters.Codewars (newFormatter , escapeLF )
77import Test.Hspec.Core.Formatters.V2 (formatterToFormat , formatException )
88import Test.Hspec.Core.Util (safeTry )
99
1010import qualified Spec
1111
1212main :: IO ()
1313main = do
14- formatter <- codewars
15- summary <- safeTry $ runSpec Spec. spec defaultConfig {configFormat = Just $ formatterToFormat formatter }
14+ codewars <- newFormatter
15+ summary <- safeTry $ runSpec Spec. spec defaultConfig {configFormat = Just $ formatterToFormat codewars }
1616 case summary of
1717 Left ex -> do
1818 putStrLn $ " \n <ERROR::>Test suite crashed<:LF:>" ++ (escapeLF $ formatException ex)
You can’t perform that action at this time.
0 commit comments