Skip to content

Commit

Permalink
Do not depend on unbounded-delays on 64-bit architecture
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Aug 8, 2022
1 parent 7c8a1af commit 9ad34aa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
12 changes: 10 additions & 2 deletions core/Test/Tasty/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ module Test.Tasty.Run
import qualified Data.IntMap as IntMap
import qualified Data.Sequence as Seq
import qualified Data.Foldable as F
import Data.Int (Int64)
import Data.Maybe
import Data.List (intercalate)
import Data.Graph (SCC(..), stronglyConnComp)
Expand All @@ -23,7 +24,6 @@ import Control.Monad.Trans.Reader (ReaderT(..), local, ask)
import Control.Monad.Trans.Writer (WriterT(..), execWriterT, mapWriterT, tell)
import Control.Concurrent
import Control.Concurrent.STM
import Control.Concurrent.Timeout (timeout)
import Control.Concurrent.Async
import Control.Exception as E
import Control.Applicative
Expand All @@ -32,6 +32,12 @@ import Data.Monoid (First(..))
import GHC.Conc (labelThread)
import Prelude -- Silence AMP and FTP import warnings

#ifdef MIN_VERSION_unbounded_delays
import Control.Concurrent.Timeout (timeout)
#else
import System.Timeout (timeout)
#endif

import Test.Tasty.Core
import Test.Tasty.Parallel
import Test.Tasty.Patterns
Expand Down Expand Up @@ -173,7 +179,9 @@ executeTest action statusVar timeoutOpt inits fins = mask $ \restore -> do
, resultTime = fromIntegral t
, resultDetailsPrinter = noResultDetails
}
fromMaybe timeoutResult <$> timeout t a
-- If compiled with unbounded-delays then t' :: Integer, otherwise t' :: Int
let t' = fromInteger (min (max 0 t) (toInteger (maxBound :: Int64)))
fromMaybe timeoutResult <$> timeout t' a

-- destroyResources should not be interrupted by an exception
-- Here's how we ensure this:
Expand Down
7 changes: 6 additions & 1 deletion core/tasty.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ library
transformers >= 0.5,
tagged >= 0.5,
optparse-applicative >= 0.14,
unbounded-delays >= 0.1,
ansi-terminal >= 0.9

-- No reason to depend on unbounded-delays on 64-bit architecture
if(!arch(x86_64) && !arch(aarch64))
build-depends:
unbounded-delays >= 0.1

if(!impl(ghc >= 8.0))
build-depends: semigroups

Expand Down

0 comments on commit 9ad34aa

Please sign in to comment.