{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE RankNTypes #-}
module Distribution.TestSuite
( TestInstance(..)
, OptionDescr(..)
, OptionType(..)
, Test(..)
, Options
, Progress(..)
, Result(..)
, testGroup
) where
import Prelude ()
import Distribution.Compat.Prelude
data TestInstance = TestInstance
{ TestInstance -> IO Progress
run :: IO Progress
, TestInstance -> String
name :: String
, TestInstance -> [String]
tags :: [String]
, TestInstance -> [OptionDescr]
options :: [OptionDescr]
, TestInstance -> String -> String -> Either String TestInstance
setOption :: String -> String -> Either String TestInstance
}
data OptionDescr = OptionDescr
{ OptionDescr -> String
optionName :: String
, OptionDescr -> String
optionDescription :: String
, OptionDescr -> OptionType
optionType :: OptionType
, OptionDescr -> Maybe String
optionDefault :: Maybe String
}
deriving (OptionDescr -> OptionDescr -> Bool
(OptionDescr -> OptionDescr -> Bool)
-> (OptionDescr -> OptionDescr -> Bool) -> Eq OptionDescr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OptionDescr -> OptionDescr -> Bool
== :: OptionDescr -> OptionDescr -> Bool
$c/= :: OptionDescr -> OptionDescr -> Bool
/= :: OptionDescr -> OptionDescr -> Bool
Eq, ReadPrec [OptionDescr]
ReadPrec OptionDescr
Int -> ReadS OptionDescr
ReadS [OptionDescr]
(Int -> ReadS OptionDescr)
-> ReadS [OptionDescr]
-> ReadPrec OptionDescr
-> ReadPrec [OptionDescr]
-> Read OptionDescr
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS OptionDescr
readsPrec :: Int -> ReadS OptionDescr
$creadList :: ReadS [OptionDescr]
readList :: ReadS [OptionDescr]
$creadPrec :: ReadPrec OptionDescr
readPrec :: ReadPrec OptionDescr
$creadListPrec :: ReadPrec [OptionDescr]
readListPrec :: ReadPrec [OptionDescr]
Read, Int -> OptionDescr -> ShowS
[OptionDescr] -> ShowS
OptionDescr -> String
(Int -> OptionDescr -> ShowS)
-> (OptionDescr -> String)
-> ([OptionDescr] -> ShowS)
-> Show OptionDescr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OptionDescr -> ShowS
showsPrec :: Int -> OptionDescr -> ShowS
$cshow :: OptionDescr -> String
show :: OptionDescr -> String
$cshowList :: [OptionDescr] -> ShowS
showList :: [OptionDescr] -> ShowS
Show)
data OptionType
= OptionFile
{ OptionType -> Bool
optionFileMustExist :: Bool
, OptionType -> Bool
optionFileIsDir :: Bool
, OptionType -> [String]
optionFileExtensions :: [String]
}
| OptionString
{ OptionType -> Bool
optionStringMultiline :: Bool
}
| OptionNumber
{ OptionType -> Bool
optionNumberIsInt :: Bool
, OptionType -> (Maybe String, Maybe String)
optionNumberBounds :: (Maybe String, Maybe String)
}
| OptionBool
| OptionEnum [String]
| OptionSet [String]
| OptionRngSeed
deriving (OptionType -> OptionType -> Bool
(OptionType -> OptionType -> Bool)
-> (OptionType -> OptionType -> Bool) -> Eq OptionType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: OptionType -> OptionType -> Bool
== :: OptionType -> OptionType -> Bool
$c/= :: OptionType -> OptionType -> Bool
/= :: OptionType -> OptionType -> Bool
Eq, ReadPrec [OptionType]
ReadPrec OptionType
Int -> ReadS OptionType
ReadS [OptionType]
(Int -> ReadS OptionType)
-> ReadS [OptionType]
-> ReadPrec OptionType
-> ReadPrec [OptionType]
-> Read OptionType
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS OptionType
readsPrec :: Int -> ReadS OptionType
$creadList :: ReadS [OptionType]
readList :: ReadS [OptionType]
$creadPrec :: ReadPrec OptionType
readPrec :: ReadPrec OptionType
$creadListPrec :: ReadPrec [OptionType]
readListPrec :: ReadPrec [OptionType]
Read, Int -> OptionType -> ShowS
[OptionType] -> ShowS
OptionType -> String
(Int -> OptionType -> ShowS)
-> (OptionType -> String)
-> ([OptionType] -> ShowS)
-> Show OptionType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> OptionType -> ShowS
showsPrec :: Int -> OptionType -> ShowS
$cshow :: OptionType -> String
show :: OptionType -> String
$cshowList :: [OptionType] -> ShowS
showList :: [OptionType] -> ShowS
Show)
data Test
= Test TestInstance
| Group
{ Test -> String
groupName :: String
, Test -> Bool
concurrently :: Bool
, Test -> [Test]
groupTests :: [Test]
}
| [OptionDescr] Test
type Options = [(String, String)]
data Progress = Finished Result
| Progress String (IO Progress)
data Result = Pass
| Fail String
| Error String
deriving (Result -> Result -> Bool
(Result -> Result -> Bool)
-> (Result -> Result -> Bool) -> Eq Result
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Result -> Result -> Bool
== :: Result -> Result -> Bool
$c/= :: Result -> Result -> Bool
/= :: Result -> Result -> Bool
Eq, ReadPrec [Result]
ReadPrec Result
Int -> ReadS Result
ReadS [Result]
(Int -> ReadS Result)
-> ReadS [Result]
-> ReadPrec Result
-> ReadPrec [Result]
-> Read Result
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Result
readsPrec :: Int -> ReadS Result
$creadList :: ReadS [Result]
readList :: ReadS [Result]
$creadPrec :: ReadPrec Result
readPrec :: ReadPrec Result
$creadListPrec :: ReadPrec [Result]
readListPrec :: ReadPrec [Result]
Read, Int -> Result -> ShowS
[Result] -> ShowS
Result -> String
(Int -> Result -> ShowS)
-> (Result -> String) -> ([Result] -> ShowS) -> Show Result
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Result -> ShowS
showsPrec :: Int -> Result -> ShowS
$cshow :: Result -> String
show :: Result -> String
$cshowList :: [Result] -> ShowS
showList :: [Result] -> ShowS
Show)
testGroup :: String -> [Test] -> Test
testGroup :: String -> [Test] -> Test
testGroup String
n [Test]
ts = Group { groupName :: String
groupName = String
n, concurrently :: Bool
concurrently = Bool
True, groupTests :: [Test]
groupTests = [Test]
ts }