| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
System.Taffybar.Test.UtilSpec
Synopsis
- spec :: Spec
- withMockCommand :: FilePath -> String -> IO a -> IO a
- writeScript :: FilePath -> String -> IO ()
- withEnv :: [(String, Maybe String -> Maybe String)] -> IO a -> IO a
- withSetEnv :: [(String, String)] -> IO a -> IO a
- prependPath :: FilePath -> Maybe String -> Maybe String
- withService :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a
- setStdoutCond :: Priority -> ProcessConfig i o e -> ProcessConfig i () e
- setStderrCond :: Priority -> ProcessConfig i o e -> ProcessConfig i o ()
- setServiceDefaults :: Priority -> ProcessConfig i o e -> ProcessConfig () () ()
- makeServiceDefaults :: FilePath -> [String] -> IO (ProcessConfig () () ())
- listLiveThreads :: IO [(ThreadId, (String, Maybe ThreadStatus))]
- diffLiveThreads :: Eq a => [(a, b)] -> [(a, b)] -> [(a, b)]
- listFds :: MonadIO m => m [(Int, FilePath)]
- tryIOMaybe :: MonadUnliftIO m => m a -> m (Maybe a)
- laxTimeout :: (HasCallStack, MonadUnliftIO m) => Int -> m a -> m (Maybe a)
- laxTimeout' :: (HasCallStack, MonadUnliftIO m) => Int -> m a -> m a
- newtype DodgyEq a = DodgyEq {
- unDodgyEq :: a
- logSetup :: HasCallStack => SpecWith a -> SpecWith a
- specLogSetup :: IO ()
- specLogSetupPrio :: Priority -> IO ()
- specLog :: MonadIO m => String -> m ()
- specLogAt :: MonadIO m => Priority -> String -> m ()
- getSpecLogPriority :: MonadIO m => m Priority
- data Priority
Documentation
Mock commands
Arguments
| :: FilePath | Name of command - should not contain slashes |
| -> String | Contents of script |
| -> IO a | Action to run with command available in search path |
| -> IO a |
Run the given IO action with the PATH environment variable
set up so that executing the given command name will run a
script.
writeScript :: FilePath -> String -> IO () Source #
Write a text file, make it executable. It ought to have a shebang line.
Environment setup
prependPath :: FilePath -> Maybe String -> Maybe String Source #
Use this as a modifier function argument of withEnv to ensure
that the given directory is prepended to a search path variable.
Running subprocesses
withService :: MonadUnliftIO m => ProcessConfig stdin stdout stderr -> (Process stdin stdout stderr -> m a) -> m a Source #
Like withProcessTerm_, except that if the process exits -- for
whatever reason -- before the action completes, then it's an
error. It will immediately cancel the action and throw an
ExitCodeException.
setStdoutCond :: Priority -> ProcessConfig i o e -> ProcessConfig i () e Source #
setStderrCond :: Priority -> ProcessConfig i o e -> ProcessConfig i o () Source #
setServiceDefaults :: Priority -> ProcessConfig i o e -> ProcessConfig () () () Source #
Concurrency
listLiveThreads :: IO [(ThreadId, (String, Maybe ThreadStatus))] Source #
diffLiveThreads :: Eq a => [(a, b)] -> [(a, b)] -> [(a, b)] Source #
OS Resources
Other test helpers
tryIOMaybe :: MonadUnliftIO m => m a -> m (Maybe a) Source #
laxTimeout :: (HasCallStack, MonadUnliftIO m) => Int -> m a -> m (Maybe a) Source #
laxTimeout' :: (HasCallStack, MonadUnliftIO m) => Int -> m a -> m a Source #
Logging for tests
logSetup :: HasCallStack => SpecWith a -> SpecWith a Source #
Setup logging before running the specs.
specLogSetup :: IO () Source #
Get log levels from environment variables and set up formatters.
specLogSetupPrio :: Priority -> IO () Source #
Like specLogSetup, but with a default minimum priority.
getSpecLogPriority :: MonadIO m => m Priority Source #
Find out the configured log level for specs.
Instances
| NFData Priority | |||||
Defined in System.Log | |||||
| Data Priority | |||||
Defined in System.Log Methods gfoldl :: (forall d b. Data d => c (d -> b) -> d -> c b) -> (forall g. g -> c g) -> Priority -> c Priority Source # gunfold :: (forall b r. Data b => c (b -> r) -> c r) -> (forall r. r -> c r) -> Constr -> c Priority Source # toConstr :: Priority -> Constr Source # dataTypeOf :: Priority -> DataType Source # dataCast1 :: Typeable t => (forall d. Data d => c (t d)) -> Maybe (c Priority) Source # dataCast2 :: Typeable t => (forall d e. (Data d, Data e) => c (t d e)) -> Maybe (c Priority) Source # gmapT :: (forall b. Data b => b -> b) -> Priority -> Priority Source # gmapQl :: (r -> r' -> r) -> r -> (forall d. Data d => d -> r') -> Priority -> r Source # gmapQr :: forall r r'. (r' -> r -> r) -> r -> (forall d. Data d => d -> r') -> Priority -> r Source # gmapQ :: (forall d. Data d => d -> u) -> Priority -> [u] Source # gmapQi :: Int -> (forall d. Data d => d -> u) -> Priority -> u Source # gmapM :: Monad m => (forall d. Data d => d -> m d) -> Priority -> m Priority Source # gmapMp :: MonadPlus m => (forall d. Data d => d -> m d) -> Priority -> m Priority Source # gmapMo :: MonadPlus m => (forall d. Data d => d -> m d) -> Priority -> m Priority Source # | |||||
| Bounded Priority | |||||
| Enum Priority | |||||
Defined in System.Log Methods succ :: Priority -> Priority Source # pred :: Priority -> Priority Source # toEnum :: Int -> Priority Source # fromEnum :: Priority -> Int Source # enumFrom :: Priority -> [Priority] Source # enumFromThen :: Priority -> Priority -> [Priority] Source # enumFromTo :: Priority -> Priority -> [Priority] Source # enumFromThenTo :: Priority -> Priority -> Priority -> [Priority] Source # | |||||
| Generic Priority | |||||
Defined in System.Log Associated Types
| |||||
| Read Priority | |||||
| Show Priority | |||||
| Eq Priority | |||||
| Ord Priority | |||||
Defined in System.Log | |||||
| type Rep Priority | |||||
Defined in System.Log type Rep Priority = D1 ('MetaData "Priority" "System.Log" "hslogger-1.3.2.0-7InjwZUz8RN2lItqNTj9Ba" 'False) (((C1 ('MetaCons "DEBUG" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "INFO" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "NOTICE" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "WARNING" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "ERROR" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "CRITICAL" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "ALERT" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "EMERGENCY" 'PrefixI 'False) (U1 :: Type -> Type)))) | |||||