| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Skeletest.Internal.Hooks
Synopsis
- data Hooks = Hooks {}
- defaultHooks :: Hooks
- data UserHooks
- setUserHooks :: Hooks -> IO ()
- userHooks :: UserHooks
- newtype Hook ctx inp out = Hook [HookDef ctx inp out]
- data HookDef ctx inp out = HookDef {
- priority :: HookPriority
- impl :: ctx -> (inp -> IO out) -> inp -> IO out
- data HookPriority
- runHook :: Hook ctx inp out -> ctx -> inp -> (inp -> IO out) -> IO out
- runEarly :: Hook ctx inp out -> Hook ctx inp out
- runLate :: Hook ctx inp out -> Hook ctx inp out
- mkHook :: (ctx -> (inp -> IO out) -> inp -> IO out) -> Hook ctx inp out
- mkHook_ :: (ctx -> inp -> IO ()) -> (ctx -> inp -> out -> IO ()) -> Hook ctx inp out
- mkPreHook :: (ctx -> inp -> IO inp) -> Hook ctx inp out
- mkPreHook_ :: (ctx -> inp -> IO ()) -> Hook ctx inp out
- mkPostHook :: (ctx -> inp -> out -> IO out) -> Hook ctx inp out
- mkPostHook_ :: (ctx -> inp -> out -> IO ()) -> Hook ctx inp out
- type ModifySpecRegistryHook = Hook ModifySpecRegistryHookContext SpecRegistry SpecRegistry
- data ModifySpecRegistryHookContext = ModifySpecRegistryHookContext {}
- type RunTestHook = Hook RunTestHookContext () TestResult
- data RunTestHookContext = RunTestHookContext {}
- type OnTestFailureHook = Hook OnTestFailureHookContext SomeException TestResult
- data OnTestFailureHookContext = OnTestFailureHookContext {}
- type RunSpecsHook = Hook RunSpecsHookContext SpecRegistry TestExitCode
- data RunSpecsHookContext = RunSpecsHookContext
- type ModifyTestSummaryHook = Hook ModifyTestSummaryHookContext Text Text
- data ModifyTestSummaryHookContext = ModifyTestSummaryHookContext
Documentation
Hooks for extending Skeletest.
Use defaultHooks instead of using Hooks directly, to minimize
breaking changes.
Constructors
| Hooks | |
defaultHooks :: Hooks Source #
Runtime
setUserHooks :: Hooks -> IO () Source #
Hook implementation
newtype Hook ctx inp out Source #
The implementation of a Skeletest hook in Hooks.
A hook of type Hook ctx inp out means:
- The hook takes a value of type
ctxwith extra read-only information that may be relevant for the hook. - The hook takes an action of type
inp -> IO outand returns a potentially modified action of the same type.
ctx/inp should generally be accessed with OverloadedRecordDot or record
destructuring, to minimize breaking changes when adding fields to them.
data HookPriority Source #
Constructors
| NoPriority | |
| EarlyPriority | |
| LatePriority |
Hook DSL
mkHook :: (ctx -> (inp -> IO out) -> inp -> IO out) -> Hook ctx inp out Source #
Create a hook.
Example
hooks :: Hooks
hooks =
defaultHooks
{ runSpecs = runEarly . mkHook $ ctx run -> pre >=> run >=> post
}
where
pre inp = do
inp' <- doStuff inp
pure inp'
post out = do
out' <- doMoreStuff out
pure out'
mkHook_ :: (ctx -> inp -> IO ()) -> (ctx -> inp -> out -> IO ()) -> Hook ctx inp out Source #
Like mkHook, except for read-only hooks that don't need to modify
anything.
mkPreHook :: (ctx -> inp -> IO inp) -> Hook ctx inp out Source #
Like mkHook, except only supports modifying the input.
mkPreHook_ :: (ctx -> inp -> IO ()) -> Hook ctx inp out Source #
Like mkHook_, except with only a before action.
mkPostHook :: (ctx -> inp -> out -> IO out) -> Hook ctx inp out Source #
Like mkHook, except only supports modifying the output.
mkPostHook_ :: (ctx -> inp -> out -> IO ()) -> Hook ctx inp out Source #
Like mkHook_, except with only an after action.
Specific hooks
modifySpecRegistry
type ModifySpecRegistryHook = Hook ModifySpecRegistryHookContext SpecRegistry SpecRegistry Source #
Modify the specs in the test suite.
data ModifySpecRegistryHookContext Source #
Constructors
| ModifySpecRegistryHookContext | |
Fields | |
runTest
type RunTestHook = Hook RunTestHookContext () TestResult Source #
Modify how a test is executed
data RunTestHookContext Source #
Constructors
| RunTestHookContext | |
onTestFailure
type OnTestFailureHook = Hook OnTestFailureHookContext SomeException TestResult Source #
Modify what happens if a test fails.
data OnTestFailureHookContext Source #
Constructors
| OnTestFailureHookContext | |
runSpecs
type RunSpecsHook = Hook RunSpecsHookContext SpecRegistry TestExitCode Source #
Modify the action to run specs.
data RunSpecsHookContext Source #
Constructors
| RunSpecsHookContext |
modifyTestSummary
type ModifyTestSummaryHook = Hook ModifyTestSummaryHookContext Text Text Source #
Modify the test summary at the end of the report.
data ModifyTestSummaryHookContext Source #
Constructors
| ModifyTestSummaryHookContext |