Un-ignore .bat files
[cabal.git] / cabal-testsuite / PackageTests / TestSuiteTests / ExeV10 / cabal-with-hpc.multitest.hs
blob14f122475485e9b7401ea4e1db006d1e88320ecc
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
11 main = cabalTest $ do
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) ->
21 let
22 opts = catMaybes
23 [ enable libProf "library-profiling"
24 , enable exeProf "profiling"
25 , enable exeDyn "executable-dynamic"
26 , enable shared "shared"
28 where
29 enable cond flag
30 | cond = Just $ "--enable-" ++ flag
31 | otherwise = Nothing
32 args = "test-Short" : "--enable-coverage" : opts
33 recordMode DoNotRecord $ do
34 let
35 skip =
36 not hpcOk
37 || (not hasShared && (exeDyn || shared))
38 || (not hasProfiled && (libProf || exeProf))
39 unless skip $ cabal "v2-test" args
40 where
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)
52 where
53 -- Distribution.Compat.Exception is hidden.
54 catchIO :: IO a -> (E.IOException -> IO a) -> IO a
55 catchIO = E.catch