1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE RankNTypes #-}
4 -----------------------------------------------------------------------------
7 -- Module : Distribution.TestSuite
8 -- Copyright : Thomas Tuegel 2010
11 -- Maintainer : cabal-devel@haskell.org
12 -- Portability : portable
14 -- This module defines the detailed test suite interface which makes it
15 -- possible to expose individual tests to Cabal or other test agents.
16 module Distribution
.TestSuite
27 import Distribution
.Compat
.Prelude
30 data TestInstance
= TestInstance
32 -- ^ Perform the test.
34 -- ^ A name for the test, unique within a
37 -- ^ Users can select groups of tests by
39 , options
:: [OptionDescr
]
40 -- ^ Descriptions of the options recognized
42 , setOption
:: String -> String -> Either String TestInstance
43 -- ^ Try to set the named option to the given value. Returns an error
44 -- message if the option is not supported or the value could not be
45 -- correctly parsed; otherwise, a 'TestInstance' with the option set to
46 -- the given value is returned.
49 data OptionDescr
= OptionDescr
50 { optionName
:: String
51 , optionDescription
:: String
52 -- ^ A human-readable description of the
53 -- option to guide the user setting it.
54 , optionType
:: OptionType
55 , optionDefault
:: Maybe String
57 deriving (Eq
, Read, Show)
61 { optionFileMustExist
:: Bool
62 , optionFileIsDir
:: Bool
63 , optionFileExtensions
:: [String]
66 { optionStringMultiline
:: Bool
69 { optionNumberIsInt
:: Bool
70 , optionNumberBounds
:: (Maybe String, Maybe String)
76 deriving (Eq
, Read, Show)
82 , concurrently
:: Bool
83 -- ^ If true, then children of this group may be run in parallel.
84 -- Note that this setting is not inherited by children. In
85 -- particular, consider a group F with "concurrently = False" that
86 -- has some children, including a group T with "concurrently =
87 -- True". The children of group T may be run concurrently with each
88 -- other, as long as none are run at the same time as any of the
89 -- direct children of group F.
90 , groupTests
:: [Test
]
92 | ExtraOptions
[OptionDescr
] Test
94 type Options
= [(String, String)]
98 | Progress
String (IO Progress
)
104 deriving (Eq
, Read, Show)
106 -- | Create a named group of tests, which are assumed to be safe to run in
108 testGroup
:: String -> [Test
] -> Test
109 testGroup n ts
= Group
{groupName
= n
, concurrently
= True, groupTests
= ts
}