make LTS branch pre-releases
[cabal.git] / Cabal-syntax / src / Distribution / Types / TestType.hs
blob6ac0866d6f1452bec405d6c31731a308a1c65a23
1 {-# LANGUAGE DeriveDataTypeable #-}
2 {-# LANGUAGE DeriveGeneric #-}
3 {-# LANGUAGE OverloadedStrings #-}
5 module Distribution.Types.TestType
6 ( TestType (..)
7 , knownTestTypes
8 , testTypeExe
9 , testTypeLib
10 ) where
12 import Distribution.Compat.Prelude
13 import Distribution.Version
14 import Prelude ()
16 import Distribution.Parsec
17 import Distribution.Pretty
18 import Text.PrettyPrint (char, text)
20 -- | The \"test-type\" field in the test suite stanza.
21 data TestType
22 = -- | \"type: exitcode-stdio-x.y\"
23 TestTypeExe Version
24 | -- | \"type: detailed-x.y\"
25 TestTypeLib Version
26 | -- | Some unknown test type e.g. \"type: foo\"
27 TestTypeUnknown String Version
28 deriving (Generic, Show, Read, Eq, Ord, Typeable, Data)
30 instance Binary TestType
31 instance Structured TestType
33 instance NFData TestType where rnf = genericRnf
35 knownTestTypes :: [TestType]
36 knownTestTypes =
37 [ testTypeExe
38 , testTypeLib
41 testTypeExe :: TestType
42 testTypeExe = TestTypeExe (mkVersion [1, 0])
44 testTypeLib :: TestType
45 testTypeLib = TestTypeLib (mkVersion [0, 9])
47 instance Pretty TestType where
48 pretty (TestTypeExe ver) = text "exitcode-stdio-" <<>> pretty ver
49 pretty (TestTypeLib ver) = text "detailed-" <<>> pretty ver
50 pretty (TestTypeUnknown name ver) = text name <<>> char '-' <<>> pretty ver
52 instance Parsec TestType where
53 parsec = parsecStandard $ \ver name -> case name of
54 "exitcode-stdio" -> TestTypeExe ver
55 "detailed" -> TestTypeLib ver
56 _ -> TestTypeUnknown name ver