1 import qualified Control
.Exception
as E
(IOException
, catch)
2 import Control
.Monad
(unless)
3 import Control
.Monad
.IO.Class
(liftIO
)
4 import Control
.Monad
.Trans
.Reader
(ask
)
5 import Data
.Maybe (catMaybes)
7 import qualified Distribution
.Verbosity
as Verbosity
9 import Test
.Cabal
.Prelude
14 hasShared
<- hasSharedLibraries
15 hasProfiled
<- hasProfiledLibraries
16 hpcOk
<- correctHpcVersion
18 forM_
(choose4
[True, False]) $ \(libProf
, exeProf
, exeDyn
, shared
) ->
22 [ enable libProf
"library-profiling"
23 , enable exeProf
"profiling"
24 , enable exeDyn
"executable-dynamic"
25 , enable shared
"shared"
29 | cond
= Just
$ "--enable-" ++ flag
31 args
= "test-Short" : "--enable-coverage" : opts
32 recordMode DoNotRecord
$ do
36 ||
(not hasShared
&& (exeDyn || shared
))
37 ||
(not hasProfiled
&& (libProf || exeProf
))
38 unless skip
$ cabal
"v2-test" args
40 choose4
:: [a
] -> [(a
, a
, a
, a
)]
41 choose4 xs
= liftM4 (,,,) xs xs xs xs
43 -- | Checks for a suitable HPC version for testing.
44 correctHpcVersion
:: TestM
Bool
45 correctHpcVersion
= do
46 let verbosity
= Verbosity
.normal
47 verRange
= orLaterVersion
(mkVersion
[0,7])
48 progDB
<- testProgramDb `
fmap` ask
49 liftIO
$ (requireProgramVersion verbosity hpcProgram verRange progDB
50 >> return True) `catchIO`
(\_
-> return False)
52 -- Distribution.Compat.Exception is hidden.
53 catchIO
:: IO a
-> (E
.IOException
-> IO a
) -> IO a