{-# LANGUAGE ViewPatterns #-}
module Test.Hspec.Api.Formatters.V3 (
registerFormatter
, useFormatter
, formatterToFormat
, silent
, checks
, specdoc
, progress
, failed_examples
, Formatter (..)
, Path
, Progress
, Location(..)
, Item(..)
, Result(..)
, FailureReason (..)
, FormatM
, getConfig
, getConfigValue
, FormatConfig(..)
, defaultFormatConfig
, getSuccessCount
, getPendingCount
, getFailCount
, getTotalCount
, getExpectedTotalCount
, FailureRecord (..)
, getFailMessages
, usedSeed
, printTimes
, Seconds(..)
, getCPUTime
, getRealTime
, write
, writeLine
, writeTransient
, withInfoColor
, withSuccessColor
, withPendingColor
, withFailColor
, outputUnicode
, useDiff
, diffContext
, externalDiffAction
, prettyPrint
, prettyPrintFunction
, extraChunk
, missingChunk
, unlessExpert
, formatLocation
, formatException
, SpecWith
, Config
, modifyConfig
) where
import Test.Hspec.Core.Formatters.V2 hiding (FormatConfig(..), getConfig, getConfigValue)
import qualified Test.Hspec.Core.Formatters.V2 as Core
import Test.Hspec.Core.Runner (Config(..))
import Test.Hspec.Core.Format (Format)
import Test.Hspec.Core.Spec (modifyConfig, SpecWith)
import Test.Hspec.Api.Format.V2.Config
getConfig :: FormatM FormatConfig
getConfig :: FormatM FormatConfig
getConfig = FormatConfig -> FormatConfig
unliftFormatConfig (FormatConfig -> FormatConfig)
-> FormatM FormatConfig -> FormatM FormatConfig
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FormatM FormatConfig
Core.getConfig
getConfigValue :: (FormatConfig -> a) -> FormatM a
getConfigValue :: forall a. (FormatConfig -> a) -> FormatM a
getConfigValue FormatConfig -> a
f = FormatConfig -> a
f (FormatConfig -> a) -> FormatM FormatConfig -> FormatM a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> FormatM FormatConfig
getConfig
registerFormatter :: (String, Formatter) -> Config -> Config
registerFormatter :: (String, Formatter) -> Config -> Config
registerFormatter (String, Formatter)
formatter = (String, FormatConfig -> IO Format) -> Config -> Config
registerFormatter_ ((Formatter -> FormatConfig -> IO Format)
-> (String, Formatter) -> (String, FormatConfig -> IO Format)
forall a b. (a -> b) -> (String, a) -> (String, b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Formatter -> FormatConfig -> IO Format
formatterToFormat (String, Formatter)
formatter)
useFormatter :: (String, Formatter) -> Config -> Config
useFormatter :: (String, Formatter) -> Config -> Config
useFormatter ((Formatter -> FormatConfig -> IO Format)
-> (String, Formatter) -> (String, FormatConfig -> IO Format)
forall a b. (a -> b) -> (String, a) -> (String, b)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Formatter -> FormatConfig -> IO Format
formatterToFormat -> formatter :: (String, FormatConfig -> IO Format)
formatter@(String
_, FormatConfig -> IO Format
format)) Config
config = ((String, FormatConfig -> IO Format) -> Config -> Config
registerFormatter_ (String, FormatConfig -> IO Format)
formatter Config
config) { configFormat = Just format }
registerFormatter_ :: (String, Core.FormatConfig -> IO Format) -> Config -> Config
registerFormatter_ :: (String, FormatConfig -> IO Format) -> Config -> Config
registerFormatter_ (String, FormatConfig -> IO Format)
formatter Config
config = Config
config { configAvailableFormatters = formatter : configAvailableFormatters config }