{-# OPTIONS_GHC -fno-warn-deprecations #-}
module Test.Hspec.Core.Extension {-# WARNING "This API is experimental." #-} (
runIO
, modifyConfig
, Option
, registerOptions
, registerTransformation
, Config
, Item
, SpecM
, SpecWith
, SpecTree
) where
import Prelude ()
import Test.Hspec.Core.Compat
import qualified Data.CallStack as CallStack
import qualified GetOpt.Declarative as Declarative
import Test.Hspec.Core.Spec (SpecM, SpecWith, runIO, modifyConfig)
import qualified Test.Hspec.Core.Spec as Core
import qualified Test.Hspec.Core.Config.Definition as Core
import Test.Hspec.Core.Extension.Config (Config)
import qualified Test.Hspec.Core.Extension.Config.Type as Config
import Test.Hspec.Core.Extension.Option
import Test.Hspec.Core.Extension.Item
import Test.Hspec.Core.Extension.Tree
registerOptions :: HasCallStack => [Option] -> SpecWith a
registerOptions :: forall a. HasCallStack => [Option] -> SpecWith a
registerOptions = (Config -> Config) -> SpecWith a
forall a. (Config -> Config) -> SpecWith a
Core.modifyConfig ((Config -> Config) -> SpecWith a)
-> ([Option] -> Config -> Config) -> [Option] -> SpecWith a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> [Option Config] -> Config -> Config
Core.addExtensionOptions String
section ([Option Config] -> Config -> Config)
-> ([Option] -> [Option Config]) -> [Option] -> Config -> Config
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Option -> Option Config) -> [Option] -> [Option Config]
forall a b. (a -> b) -> [a] -> [b]
map Option -> Option Config
liftOption
where
section :: String
section = String
"OPTIONS FOR " String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
package
package :: String
package = String
-> ((String, SrcLoc) -> String) -> Maybe (String, SrcLoc) -> String
forall b a. b -> (a -> b) -> Maybe a -> b
maybe String
"main" (SrcLoc -> String
CallStack.srcLocPackage (SrcLoc -> String)
-> ((String, SrcLoc) -> SrcLoc) -> (String, SrcLoc) -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (String, SrcLoc) -> SrcLoc
forall a b. (a, b) -> b
snd) Maybe (String, SrcLoc)
HasCallStack => Maybe (String, SrcLoc)
CallStack.callSite
liftOption :: Option -> Declarative.Option Core.Config
liftOption :: Option -> Option Config
liftOption = Option -> Option Config
Config.unOption
registerTransformation :: (Config -> [SpecTree] -> [SpecTree]) -> SpecWith a
registerTransformation :: forall a. (Config -> [SpecTree] -> [SpecTree]) -> SpecWith a
registerTransformation = (Config -> Config) -> SpecWith a
forall a. (Config -> Config) -> SpecWith a
modifyConfig ((Config -> Config) -> SpecWith a)
-> ((Config -> [SpecTree] -> [SpecTree]) -> Config -> Config)
-> (Config -> [SpecTree] -> [SpecTree])
-> SpecWith a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Config -> [SpecTree] -> [SpecTree]) -> Config -> Config
Config.addSpecTransformation