-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A testing library for command line applications. -- -- Allows to write tests for command line applications using haskell. @package hcltest @version 0.3.3 -- | A Trace is a log entry for a single test step. module Test.HClTest.Trace -- | A trace has a step description and some messages produced by that step -- in it. data Trace Trace :: String -> [String] -> Trace stepDescription :: Trace -> String messages :: Trace -> [String] -- | Pretty print a trace. showTrace :: Trace -> String module Test.HClTest.Setup -- | copyFiles source target copies all the files in the -- source directory to the directory target. copyFiles :: FilePath -> FilePath -> IO () -- | copyFilesHere source copies all the files from source to the -- current directory. copyFilesHere :: FilePath -> IO () -- | This module defines the basic test type, HClTest, which is a monad. It -- also provides functions for creating and running tests. module Test.HClTest.Monad -- | The HClTest monad. A HClTest action describes a single test case. The -- first argument is the type of the trace entries. For tests, this -- should be Trace. For a single test step, this should be -- String. newtype HClTest w a HClTest :: ReaderT Config (MaybeT (WriterT (DList w) IO)) a -> HClTest w a unHClTest :: HClTest w a -> ReaderT Config (MaybeT (WriterT (DList w) IO)) a -- | The config is passed in a Reader to the test cases. data Config Config :: Double -> Config _timeoutFactor :: Config -> Double -- | Like runHClTestTrace, but already shows the trace so that you get a -- string. runHClTest :: Double -> HClTest Trace () -> IO (Bool, String) -- | Run a HClTest. The first argument is the timeout for waiting for -- output of the process, in milliseconds. The second argument is the -- test case. -- -- This will run the test in a temporary working directory. Use the -- functions in Test.HClTest.Setup to setup the environment. -- -- Returns True when the test succeeded, False otherwise. runHClTestTrace :: Double -> HClTest Trace () -> IO (Bool, DList Trace) -- | This is a HClTest action that always fails. The first argument is the -- trace to leave. If you want to fail without leaving a trace, you can -- just use mzero. failTest :: a -> HClTest a b -- | A single test step. The first argument is a description of the step. -- The test step can produce trace messages of type String. Those -- will be collected an exactly one Trace will be emitted. testStep :: String -> HClTest String a -> HClTest Trace a -- | Add a message to the log. traceMsg :: a -> HClTest a () -- | Run an IO action, and fail if that action returns false. The first -- argument is a description of the IO action which will be used for the -- trace messages. testIO :: String -> IO Bool -> HClTest Trace () -- | Run a number of tests in parallel, in random order. The first argument -- is the number of threads to use. randomParallel :: Int -> [HClTest Trace ()] -> HClTest Trace () timeoutFactor :: Iso' Config Double instance Functor (HClTest w) instance Applicative (HClTest w) instance Monad (HClTest w) instance MonadIO (HClTest w) instance MonadPlus (HClTest w) instance Alternative (HClTest w) instance MonadReader Config (HClTest w) instance MonadBaseControl IO (HClTest w) instance MonadBase IO (HClTest w) -- | In this module there are functions for creating test cases that run -- programs. It also provides functions for running programs that require -- input. module Test.HClTest.Program -- | A output stream. data Stream Stdout :: Stream Stderr :: Stream -- | The driver monad. The driver monad is used to run programs that -- require input. It allows you to specify a script of actions, -- like send input or expect output. type Driver = Free DriverF -- | Run a driver. The first argument is the timeout for waiting for output -- of the process. The second argument are handles to stdin, stdout and -- stderr of the process. The third argument is the driver to run. This -- produces a test step. runDriver :: Int -> (Handle, Handle, Handle) -> Driver a -> HClTest String a -- | Check that the process outputs the given text on the given output -- stream. This only matches a prefix, so it also succeeds if the process -- produces more output. If you want to check that this is the only -- output, use expectEOF. expect :: Stream -> Text -> Driver () -- | Check that the process' output ended. expectEOF :: Stream -> Driver () -- | Send some text to the process. The text will be encoded as UTF-8. send :: Text -> Driver () -- | Make a test step for an interactive program. The first argument is -- either the working directory or Nothing, which doesn't change the -- working directory. The second argument is the timeout in seconds for -- waiting for output of the process. The third argument is the -- executable file. The forth argument are the arguments for the -- executable and the fifth is the driver to use. The driver should -- return the expected exit code. testInteractive :: Maybe FilePath -> Maybe [(String, String)] -> Int -> FilePath -> [String] -> Driver ExitCode -> HClTest Trace () -- | A restricted form of testInteractive that Only tests that the process -- produces the given output on stderr, and no more. See -- testInteractive for a description of the arguments. testStdout :: Maybe FilePath -> Maybe [(String, String)] -> Int -> FilePath -> [String] -> ExitCode -> Text -> HClTest Trace () -- | A restricted form of testInteractive that only tests that the process -- exits with the given exit code. See testInteractive for a -- description of the arguments. testExitCode :: Maybe FilePath -> Maybe [(String, String)] -> Int -> FilePath -> [String] -> ExitCode -> HClTest Trace () instance Show Stream instance Functor DriverF module Test.HClTest -- | This module provides support for running hcltest cases using tasty. module Test.Tasty.HClTest -- | Make a new test case with the given name using a HClTest for testing. hcltest :: TestName -> HClTest Trace () -> TestTree instance Typeable HClTasty instance Typeable HClTestTimeoutFactor instance Typeable HClTestSuccessLog instance Ord HClTestTimeoutFactor instance Num HClTestTimeoutFactor instance Eq HClTestTimeoutFactor instance Real HClTestTimeoutFactor instance IsTest HClTasty instance IsOption HClTestSuccessLog instance IsOption HClTestTimeoutFactor