module Distribution.TestSuite
( TestInstance(..)
, OptionDescr(..)
, OptionType(..)
, Test(..)
, Options
, Progress(..)
, Result(..)
, testGroup
) where
data TestInstance = TestInstance
{ run :: IO Progress
, name :: String
, tags :: [String]
, options :: [OptionDescr]
, setOption :: String -> String -> Either String TestInstance
}
data OptionDescr = OptionDescr
{ optionName :: String
, optionDescription :: String
, optionType :: OptionType
, optionDefault :: Maybe String
}
deriving (Eq, Read, Show)
data OptionType
= OptionFile
{ optionFileMustExist :: Bool
, optionFileIsDir :: Bool
, optionFileExtensions :: [String]
}
| OptionString
{ optionStringMultiline :: Bool
}
| OptionNumber
{ optionNumberIsInt :: Bool
, optionNumberBounds :: (Maybe String, Maybe String)
}
| OptionBool
| OptionEnum [String]
| OptionSet [String]
| OptionRngSeed
deriving (Eq, Read, Show)
data Test
= Test TestInstance
| Group
{ groupName :: String
, concurrently :: Bool
, groupTests :: [Test]
}
| ExtraOptions [OptionDescr] Test
type Options = [(String, String)]
data Progress = Finished Result
| Progress String (IO Progress)
data Result = Pass
| Fail String
| Error String
deriving (Eq, Read, Show)
testGroup :: String -> [Test] -> Test
testGroup n ts = Group { groupName = n, concurrently = True, groupTests = ts }