1 {-# LANGUAGE FlexibleContexts #-}
2 {-# LANGUAGE RankNTypes #-}
4 -----------------------------------------------------------------------------
6 -- Module : Distribution.TestSuite
7 -- Copyright : Thomas Tuegel 2010
10 -- Maintainer : cabal-devel@haskell.org
11 -- Portability : portable
13 -- This module defines the detailed test suite interface which makes it
14 -- possible to expose individual tests to Cabal or other test agents.
16 module Distribution
.TestSuite
28 import Distribution
.Compat
.Prelude
30 data TestInstance
= TestInstance
31 { run
:: IO Progress
-- ^ Perform the test.
32 , name
:: String -- ^ A name for the test, unique within a
34 , tags
:: [String] -- ^ Users can select groups of tests by
36 , options
:: [OptionDescr
] -- ^ Descriptions of the options recognized
38 , setOption
:: String -> String -> Either String TestInstance
39 -- ^ Try to set the named option to the given value. Returns an error
40 -- message if the option is not supported or the value could not be
41 -- correctly parsed; otherwise, a 'TestInstance' with the option set to
42 -- the given value is returned.
45 data OptionDescr
= OptionDescr
46 { optionName
:: String
47 , optionDescription
:: String -- ^ A human-readable description of the
48 -- option to guide the user setting it.
49 , optionType
:: OptionType
50 , optionDefault
:: Maybe String
52 deriving (Eq
, Read, Show)
56 { optionFileMustExist
:: Bool
57 , optionFileIsDir
:: Bool
58 , optionFileExtensions
:: [String]
61 { optionStringMultiline
:: Bool
64 { optionNumberIsInt
:: Bool
65 , optionNumberBounds
:: (Maybe String, Maybe String)
71 deriving (Eq
, Read, Show)
77 , concurrently
:: Bool
78 -- ^ If true, then children of this group may be run in parallel.
79 -- Note that this setting is not inherited by children. In
80 -- particular, consider a group F with "concurrently = False" that
81 -- has some children, including a group T with "concurrently =
82 -- True". The children of group T may be run concurrently with each
83 -- other, as long as none are run at the same time as any of the
84 -- direct children of group F.
85 , groupTests
:: [Test
]
87 | ExtraOptions
[OptionDescr
] Test
89 type Options
= [(String, String)]
91 data Progress
= Finished Result
92 | Progress
String (IO Progress
)
97 deriving (Eq
, Read, Show)
99 -- | Create a named group of tests, which are assumed to be safe to run in
101 testGroup
:: String -> [Test
] -> Test
102 testGroup n ts
= Group
{ groupName
= n
, concurrently
= True, groupTests
= ts
}