Commit e84a99a0 authored by kristenk's avatar kristenk Committed by Mikhail Glushenkov
Browse files

Rename flag that enables expensive assertions.

parent e15b2899
......@@ -55,7 +55,7 @@ matrix:
- env: GHCVER=8.0.1 SCRIPT=script PARSEC=YES TAGSUFFIX="-parsec"
os: linux
sudo: required
- env: GHCVER=8.0.1 SCRIPT=script DEBUG_ASSERTIONS=YES TAGSUFFIX="-fdebug-assertions"
- env: GHCVER=8.0.1 SCRIPT=script DEBUG_EXPENSIVE_ASSERTIONS=YES TAGSUFFIX="-fdebug-expensive-assertions"
os: linux
sudo: required
- env: GHCVER=8.0.1 SCRIPT=bootstrap
......
{-# LANGUAGE CPP #-}
module Distribution.Client.Utils.Assertion (debugAssert) where
module Distribution.Client.Utils.Assertion (expensiveAssert) where
#ifdef DEBUG_ASSERTIONS
#ifdef DEBUG_EXPENSIVE_ASSERTIONS
import Control.Exception (assert)
import Distribution.Compat.Stack
#endif
-- | Like 'assert', but only enabled with -fdebug-assertions. This function can
-- be used for expensive assertions that should only be turned on during testing
-- or debugging.
#ifdef DEBUG_ASSERTIONS
debugAssert :: WithCallStack (Bool -> a -> a)
debugAssert = assert
-- | Like 'assert', but only enabled with -fdebug-expensive-assertions. This
-- function can be used for expensive assertions that should only be turned on
-- during testing or debugging.
#ifdef DEBUG_EXPENSIVE_ASSERTIONS
expensiveAssert :: WithCallStack (Bool -> a -> a)
expensiveAssert = assert
#else
debugAssert :: Bool -> a -> a
debugAssert _ = id
expensiveAssert :: Bool -> a -> a
expensiveAssert _ = id
#endif
......@@ -137,7 +137,7 @@ newtype UpdateState a = UpdateState {
instance MonadState ValidateState UpdateState where
get = UpdateState $ get
put st = UpdateState $ do
debugAssert (lgInvariant $ vsLinks st) $ return ()
expensiveAssert (lgInvariant $ vsLinks st) $ return ()
put st
lift' :: Either Conflict a -> UpdateState a
......
......@@ -189,7 +189,7 @@ Flag network-uri
description: Get Network.URI from the network-uri package
default: True
Flag debug-assertions
Flag debug-expensive-assertions
description: Enable expensive assertions for testing or debugging
default: False
manual: True
......@@ -414,8 +414,8 @@ library
else
build-depends: unix >= 2.5 && < 2.8
if flag(debug-assertions)
cpp-options: -DDEBUG_ASSERTIONS
if flag(debug-expensive-assertions)
cpp-options: -DDEBUG_EXPENSIVE_ASSERTIONS
if flag(debug-conflict-sets)
cpp-options: -DDEBUG_CONFLICT_SETS
......@@ -506,8 +506,8 @@ executable cabal
else
build-depends: unix >= 2.5 && < 2.8
if flag(debug-assertions)
cpp-options: -DDEBUG_ASSERTIONS
if flag(debug-expensive-assertions)
cpp-options: -DDEBUG_EXPENSIVE_ASSERTIONS
if flag(debug-conflict-sets)
cpp-options: -DDEBUG_CONFLICT_SETS
......
......@@ -143,8 +143,8 @@ fi
# Needed to work around some bugs in nix-local-build code.
export CABAL_BUILDDIR="${CABAL_INSTALL_BDIR}"
if [ "x$DEBUG_ASSERTIONS" = "xYES" ]; then
CABAL_INSTALL_FLAGS=-fdebug-assertions
if [ "x$DEBUG_EXPENSIVE_ASSERTIONS" = "xYES" ]; then
CABAL_INSTALL_FLAGS=-fdebug-expensive-assertions
fi
timed cabal new-build $jobs $CABAL_INSTALL_FLAGS \
......
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