module Skeletest.Plugin (
Plugin (..),
defaultPlugin,
Hooks (..),
defaultHooks,
TestResult (..),
TestResultMessage (..),
TestInfo (..),
findMarker,
hasMarkerNamed,
) where
import Skeletest.Internal.CLI (Flag)
import Skeletest.Internal.Markers (findMarker, hasMarkerNamed)
import Skeletest.Internal.Snapshot (SnapshotRenderer)
import Skeletest.Internal.TestInfo (TestInfo (..))
import Skeletest.Internal.TestRunner (TestResult (..), TestResultMessage (..))
data Plugin = Plugin
{ Plugin -> [Flag]
cliFlags :: [Flag]
, Plugin -> [SnapshotRenderer]
snapshotRenderers :: [SnapshotRenderer]
, Plugin -> Hooks
hooks :: Hooks
}
instance Semigroup Plugin where
Plugin
plugin1 <> :: Plugin -> Plugin -> Plugin
<> Plugin
plugin2 =
Plugin
{ cliFlags :: [Flag]
cliFlags = Plugin -> [Flag]
cliFlags Plugin
plugin1 [Flag] -> [Flag] -> [Flag]
forall a. Semigroup a => a -> a -> a
<> Plugin -> [Flag]
cliFlags Plugin
plugin2
, snapshotRenderers :: [SnapshotRenderer]
snapshotRenderers = Plugin -> [SnapshotRenderer]
snapshotRenderers Plugin
plugin1 [SnapshotRenderer] -> [SnapshotRenderer] -> [SnapshotRenderer]
forall a. Semigroup a => a -> a -> a
<> Plugin -> [SnapshotRenderer]
snapshotRenderers Plugin
plugin2
, hooks :: Hooks
hooks = Plugin -> Hooks
hooks Plugin
plugin1 Hooks -> Hooks -> Hooks
forall a. Semigroup a => a -> a -> a
<> Plugin -> Hooks
hooks Plugin
plugin2
}
instance Monoid Plugin where
mempty :: Plugin
mempty = Plugin
defaultPlugin
defaultPlugin :: Plugin
defaultPlugin :: Plugin
defaultPlugin =
Plugin
{ cliFlags :: [Flag]
cliFlags = []
, snapshotRenderers :: [SnapshotRenderer]
snapshotRenderers = []
, hooks :: Hooks
hooks = Hooks
defaultHooks
}
data Hooks = Hooks
{ Hooks -> TestInfo -> IO TestResult -> IO TestResult
hookRunTest :: TestInfo -> IO TestResult -> IO TestResult
}
instance Semigroup Hooks where
Hooks
hooks1 <> :: Hooks -> Hooks -> Hooks
<> Hooks
hooks2 =
Hooks
{ hookRunTest :: TestInfo -> IO TestResult -> IO TestResult
hookRunTest = \TestInfo
testInfo -> Hooks -> TestInfo -> IO TestResult -> IO TestResult
hookRunTest Hooks
hooks2 TestInfo
testInfo (IO TestResult -> IO TestResult)
-> (IO TestResult -> IO TestResult)
-> IO TestResult
-> IO TestResult
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Hooks -> TestInfo -> IO TestResult -> IO TestResult
hookRunTest Hooks
hooks1 TestInfo
testInfo
}
instance Monoid Hooks where
mempty :: Hooks
mempty = Hooks
defaultHooks
defaultHooks :: Hooks
defaultHooks :: Hooks
defaultHooks =
Hooks
{ hookRunTest :: TestInfo -> IO TestResult -> IO TestResult
hookRunTest = \TestInfo
_ -> IO TestResult -> IO TestResult
forall a. a -> a
id
}