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