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
12 skipIf
"osx" =<< isOSX
-- TODO: re-enable this once the macOS CI
13 -- issues are resolved, see discussion in #4902.
15 hasShared
<- hasSharedLibraries
16 hasProfiled
<- hasProfiledLibraries
17 hpcOk
<- correctHpcVersion
19 forM_
(choose4
[True, False]) $ \(libProf
, exeProf
, exeDyn
, shared
) ->
23 [ enable libProf
"library-profiling"
24 , enable exeProf
"profiling"
25 , enable exeDyn
"executable-dynamic"
26 , enable shared
"shared"
30 | cond
= Just
$ "--enable-" ++ flag
32 args
= "test-Short" : "--enable-coverage" : opts
33 recordMode DoNotRecord
$ do
37 ||
(not hasShared
&& (exeDyn || shared
))
38 ||
(not hasProfiled
&& (libProf || exeProf
))
39 unless skip
$ cabal
"v2-test" args
41 choose4
:: [a
] -> [(a
, a
, a
, a
)]
42 choose4 xs
= liftM4 (,,,) xs xs xs xs
44 -- | Checks for a suitable HPC version for testing.
45 correctHpcVersion
:: TestM
Bool
46 correctHpcVersion
= do
47 let verbosity
= Verbosity
.normal
48 verRange
= orLaterVersion
(mkVersion
[0,7])
49 progDB
<- testProgramDb `
fmap` ask
50 liftIO
$ (requireProgramVersion verbosity hpcProgram verRange progDB
51 >> return True) `catchIO`
(\_
-> return False)
53 -- Distribution.Compat.Exception is hidden.
54 catchIO
:: IO a
-> (E
.IOException
-> IO a
) -> IO a