{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
module Distribution.Types.TestType (
TestType(..),
knownTestTypes,
) where
import Distribution.Compat.Prelude
import Distribution.Version
import Prelude ()
import Distribution.Parsec
import Distribution.Pretty
import Text.PrettyPrint (char, text)
data TestType = TestTypeExe Version
| TestTypeLib Version
| TestTypeUnknown String Version
deriving (Generic, Show, Read, Eq, Typeable, Data)
instance Binary TestType
instance NFData TestType where rnf = genericRnf
knownTestTypes :: [TestType]
knownTestTypes = [ TestTypeExe (mkVersion [1,0])
, TestTypeLib (mkVersion [0,9]) ]
instance Pretty TestType where
pretty (TestTypeExe ver) = text "exitcode-stdio-" <<>> pretty ver
pretty (TestTypeLib ver) = text "detailed-" <<>> pretty ver
pretty (TestTypeUnknown name ver) = text name <<>> char '-' <<>> pretty ver
instance Parsec TestType where
parsec = parsecStandard $ \ver name -> case name of
"exitcode-stdio" -> TestTypeExe ver
"detailed" -> TestTypeLib ver
_ -> TestTypeUnknown name ver