Commit 656c4249 authored by Benno Fünfstück's avatar Benno Fünfstück Committed by Edward Z. Yang
Browse files

cabal-testsuite: test that configure failure is treated as failed

parent 44352eb2
import System.Exit
main :: IO ()
main = exitFailure
{-# LANGUAGE ScopedTypeVariables #-}
import Test.Cabal.Prelude
import Data.IORef
import Control.Monad.IO.Class
import Control.Monad.Catch
import Control.Exception (ErrorCall)
main = setupTest $ do
-- the following is a hack to check that `setup configure` indeed
-- fails: all tests use `assertFailure` which uses `error` if the fail
--
-- note: we cannot use `fails $ do ...` here since that only checks that all
-- assertions fail. If there is no assertion in `m`, then `fails m` will *succeed*.
-- That's not what we want. So `fails (return ())` for example succeeds, even though
-- `return ()` doesn't fail.
succeededRef <- liftIO $ newIORef True
setup "configure" [] `catch` \(_ :: ErrorCall) ->
liftIO $ writeIORef succeededRef False
succeeded <- liftIO $ readIORef succeededRef
assertBool "test should have failed, but succeeded instead (configure exits with failure)" $ not succeeded
name: foo
version: 0.1
build-type: Custom
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment