hspec-dirstream-0.3.0.0: Helper functions to simplify adding integration tests.

Safe HaskellNone
LanguageHaskell2010

Test.Hspec.Dirstream

Contents

Synopsis

Documentation

testFiles Source #

Arguments

:: (Eq a, Show a) 
=> FilePath

Base directory

-> (FilePath -> Bool)

Filter on file extensions

-> (String -> Either a String)

Function to process a file

-> SpecWith () 

Helper function to generate a spec. The spec runs on the given directory, filtering by the given function. It then compares their output to the text of the file with .out as the new extension.

As an example, consider the directory structure

test/data
├── file.hs
└── file.out

If we have a function called formatFile and we run

testFiles "test/data" (hasExtension "hs") formatFile

This would read test/data/file.hs, format the file if it can, and compare the output to the contents of test/data/file.out.

testFilesIO :: FilePath -> (FilePath -> Bool) -> (String -> IO String) -> SpecWith () Source #

A version of the above where the return value can be any IO.

testFilesErr :: (Show b, Eq b) => FilePath -> (FilePath -> Bool) -> (String -> Either String b) -> SpecWith () Source #

This function simply tests that each file returns a Left value and that the error message contained therein matches the contents of the appropriate file.

testFilesPredicate Source #

Arguments

:: (Show a, Eq a) 
=> FilePath

Directory containing test data

-> (FilePath -> Bool)

Filter on file extensions

-> (String -> a)

Function to process the string

-> (a -> Bool)

Predicate to check the result

-> SpecWith () 

This function checks that each file returns a value satisfying the predicate.

Helper functions for dealing with file extensions

extension :: FilePath -> Maybe Text #

Get a FilePath’s last extension, or Nothing if it has no extensions.

Orphan instances

MonadIO (SpecM a) Source # 

Methods

liftIO :: IO a -> SpecM a a #

MonadThrow (SpecM a) Source # 

Methods

throwM :: Exception e => e -> SpecM a a #

MonadCatch (SpecM a) Source # 

Methods

catch :: Exception e => SpecM a a -> (e -> SpecM a a) -> SpecM a a #

MonadMask (SpecM a) Source # 

Methods

mask :: ((forall b. SpecM a b -> SpecM a b) -> SpecM a b) -> SpecM a b #

uninterruptibleMask :: ((forall b. SpecM a b -> SpecM a b) -> SpecM a b) -> SpecM a b #