1 {-# LANGUAGE ScopedTypeVariables #-}
2 import Test
.Cabal
.Prelude
4 import Control
.Monad
.IO.Class
5 import Control
.Exception
(ErrorCall
)
7 import qualified Control
.Monad
.Catch
as Catch
10 -- the following is a hack to check that `setup configure` indeed
11 -- fails: all tests use `assertFailure` which uses `error` if the fail
13 -- note: we cannot use `fails $ do ...` here since that only checks that all
14 -- assertions fail. If there is no assertion in `m`, then `fails m` will *succeed*.
15 -- That's not what we want. So `fails (return ())` for example succeeds, even though
16 -- `return ()` doesn't fail.
17 succeededRef
<- liftIO
$ newIORef
True
18 setup
"configure" [] `Catch
.catch`
\(_
:: ErrorCall
) ->
19 liftIO
$ writeIORef succeededRef
False
20 succeeded
<- liftIO
$ readIORef succeededRef
21 assertBool
"test should have failed, but succeeded instead (configure exits with failure)" $ not succeeded