Safe Haskell | None |
---|---|
Language | Haskell2010 |
Synopsis
- testFiles :: (Eq a, Show a) => FilePath -> (FilePath -> Bool) -> (String -> Either a String) -> SpecWith ()
- testFilesErr :: (Show b, Eq b) => FilePath -> PathFilter -> (String -> Either String b) -> SpecWith ()
- testFilesIO :: FilePath -> PathFilter -> (String -> IO String) -> SpecWith ()
- testFilesPure :: (Show b, Eq b) => FilePath -> PathFilter -> PathProducer -> FileProcessor a b -> SpecWith ()
- dirFiles :: PathProducer
- allFiles :: PathProducer
- extension :: FilePath -> Maybe Text
- hasExtension :: Text -> FilePath -> Bool
- data FileProcessor a b = FileProc {}
- type PathFilter = FilePath -> Bool
- type Recursor = FilePath -> ListT SafeSpecM FilePath
- type PathProducer = String -> PathFilter -> Producer String SafeSpecM ()
- type SafeSpecM = SafeT (SpecM ())
Documentation
:: (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
.
testFilesErr :: (Show b, Eq b) => FilePath -> PathFilter -> (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.
testFilesIO :: FilePath -> PathFilter -> (String -> IO String) -> SpecWith () Source #
testFilesPure :: (Show b, Eq b) => FilePath -> PathFilter -> PathProducer -> FileProcessor a b -> SpecWith () Source #
A very general means of testing files, where the check function is pure.
Configuration helper functions
Helper functions for dealing with file extensions
Types and type synonyms
data FileProcessor a b Source #
type PathFilter = FilePath -> Bool Source #
type PathProducer = String -> PathFilter -> Producer String SafeSpecM () Source #