From 9522eb15df2eb914fed6b62213d09e6e5e92dde7 Mon Sep 17 00:00:00 2001 From: Harendra Kumar Date: Fri, 1 Jan 2021 02:06:15 +0530 Subject: [PATCH] Fix -DCOVERAGE_BUILD --- cabal.project.coverage | 2 ++ test/Streamly/Test/Prelude/Concurrent.hs | 11 +++++++++++ test/Streamly/Test/Prelude/Fold.hs | 3 +++ test/Streamly/Test/Prelude/Parallel.hs | 5 ++++- test/Streamly/Test/Prelude/Serial.hs | 6 ++++-- test/lib/Streamly/Test/Prelude/Common.hs | 15 ++++++++++++--- 6 files changed, 36 insertions(+), 6 deletions(-) diff --git a/cabal.project.coverage b/cabal.project.coverage index 463889fe..7994bd87 100644 --- a/cabal.project.coverage +++ b/cabal.project.coverage @@ -9,3 +9,5 @@ package streamly package streamly-tests ghc-options: -Werror + -- A few percent lesss coverage for some build speedup + -- -DCOVERAGE_BUILD diff --git a/test/Streamly/Test/Prelude/Concurrent.hs b/test/Streamly/Test/Prelude/Concurrent.hs index c1ecc547..ea2e0518 100644 --- a/test/Streamly/Test/Prelude/Concurrent.hs +++ b/test/Streamly/Test/Prelude/Concurrent.hs @@ -352,8 +352,10 @@ main = hspec -- For concurrent application test we need a buffer of at least size 2 to -- allow two threads to run. +#ifndef COVERAGE_BUILD let makeConcurrentAppOps :: IsStream t => (t m a -> c) -> [(String, t m a -> c)] +#endif makeConcurrentAppOps t = makeCommonOps t ++ [ #ifndef COVERAGE_BUILD @@ -361,7 +363,11 @@ main = hspec #endif ] +#ifndef COVERAGE_BUILD let parallelCommonOps :: IsStream t => [(String, ParallelT m a -> t m a)] +#else + let parallelCommonOps :: [(String, ParallelT m a -> t m a)] +#endif parallelCommonOps = [] #ifndef COVERAGE_BUILD <> [("rate AvgRate 0.00000001", parallely . avgRate 0.00000001)] @@ -375,7 +381,12 @@ main = hspec -- These tests won't work with maxBuffer or maxThreads set to 1, so we -- exclude those cases from these. +#ifndef COVERAGE_BUILD let mkOps :: IsStream t => (t m a -> c) -> [(String, t m a -> c)] +#else + let mkOps :: t -> [(String, t)] + -- let mkOps :: (t m a -> c) -> [(String, t m a -> c)] +#endif mkOps t = [ ("default", t) #ifndef COVERAGE_BUILD diff --git a/test/Streamly/Test/Prelude/Fold.hs b/test/Streamly/Test/Prelude/Fold.hs index 8f5bf237..3df8b736 100644 --- a/test/Streamly/Test/Prelude/Fold.hs +++ b/test/Streamly/Test/Prelude/Fold.hs @@ -14,6 +14,9 @@ import Control.Concurrent (threadDelay) #endif import Control.Exception (ErrorCall(..), catch) import Data.IORef ( newIORef, readIORef, writeIORef, IORef ) +#ifdef COVERAGE_BUILD +import Test.Hspec.QuickCheck (modifyMaxSuccess) +#endif import Test.Hspec as H #ifdef DEVBUILD import System.Mem (performMajorGC) diff --git a/test/Streamly/Test/Prelude/Parallel.hs b/test/Streamly/Test/Prelude/Parallel.hs index e9edbdcb..3cfd8586 100644 --- a/test/Streamly/Test/Prelude/Parallel.hs +++ b/test/Streamly/Test/Prelude/Parallel.hs @@ -28,7 +28,10 @@ main = hspec $ modifyMaxSuccess (const 10) #endif $ do - let parallelCommonOps :: IsStream t => [(String, ParallelT m a -> t m a)] + let +#ifndef COVERAGE_BUILD + parallelCommonOps :: IsStream t => [(String, ParallelT m a -> t m a)] +#endif parallelCommonOps = [] #ifndef COVERAGE_BUILD <> [("rate AvgRate 0.00000001", parallely . avgRate 0.00000001)] diff --git a/test/Streamly/Test/Prelude/Serial.hs b/test/Streamly/Test/Prelude/Serial.hs index 090f3f00..1d20eecb 100644 --- a/test/Streamly/Test/Prelude/Serial.hs +++ b/test/Streamly/Test/Prelude/Serial.hs @@ -38,8 +38,10 @@ import Test.QuickCheck import Test.QuickCheck.Monadic (assert, monadicIO, pick, run) import Test.Hspec as H -import Streamly.Prelude - ( SerialT, IsStream, avgRate, maxBuffer, serial, serially) +import Streamly.Prelude (SerialT, IsStream, serial, serially) +#ifndef COVERAGE_BUILD +import Streamly.Prelude (avgRate, maxBuffer) +#endif import qualified Streamly.Prelude as S import qualified Streamly.Data.Fold as FL import qualified Streamly.Internal.Data.Unfold as UF diff --git a/test/lib/Streamly/Test/Prelude/Common.hs b/test/lib/Streamly/Test/Prelude/Common.hs index eb2c8c21..e2bfa4bf 100644 --- a/test/lib/Streamly/Test/Prelude/Common.hs +++ b/test/lib/Streamly/Test/Prelude/Common.hs @@ -127,9 +127,10 @@ import Test.Hspec import Test.QuickCheck (Property, choose, forAll, withMaxSuccess) import Test.QuickCheck.Monadic (assert, monadicIO, run) -import Streamly.Prelude - ( SerialT, IsStream, (.:), nil, (|&), serially, avgRate, rate, maxBuffer - , maxThreads, maxBuffer) +import Streamly.Prelude (SerialT, IsStream, (.:), nil, (|&), serially) +#ifndef COVERAGE_BUILD +import Streamly.Prelude (avgRate, rate, maxBuffer, maxThreads) +#endif import qualified Streamly.Prelude as S import qualified Streamly.Data.Fold as FL import qualified Streamly.Internal.Data.Fold as FL @@ -1710,7 +1711,11 @@ folded = [x] -> return x -- singleton stream case _ -> S.concatMapFoldableWith (<>) return xs) +#ifndef COVERAGE_BUILD makeCommonOps :: IsStream t => (t m a -> c) -> [(String, t m a -> c)] +#else +makeCommonOps :: b -> [(String, b)] +#endif makeCommonOps t = [ ("default", t) #ifndef COVERAGE_BUILD @@ -1723,7 +1728,11 @@ makeCommonOps t = #endif ] +#ifndef COVERAGE_BUILD makeOps :: IsStream t => (t m a -> c) -> [(String, t m a -> c)] +#else +makeOps :: b -> [(String, b)] +#endif makeOps t = makeCommonOps t ++ [ #ifndef COVERAGE_BUILD