on master help sign in
use stack builds, make coverage build faster
7f05a78Harendra Kumar
.travis.yml+6−4
@@ -86,7 +86,7 @@ matrix:
86 addons: {apt: {packages: [cabal-install-1.24,libsdl1.2-dev], sources: [hvr-ghc]}}
86 addons: {apt: {packages: [cabal-install-1.24,libsdl1.2-dev], sources: [hvr-ghc]}}
87
87
88 # Use cabal-install-1.24 for stack solver to work
88 # Use cabal-install-1.24 for stack solver to work
89− - env: BUILD=stack GHCVER=8.2.2 RESOLVER=lts-11 DISABLE_SDIST_BUILD=y DISABLE_DIST_CHECKS=y STACK_BUILD_OPTIONS="--flag streamly:diag"
89+ - env: BUILD=stack GHCVER=8.2.2 RESOLVER=lts-11 GHC_OPTIONS="" DISABLE_SDIST_BUILD=y DISABLE_DIST_CHECKS=y STACK_BUILD_OPTIONS="--flag streamly:diag"
90 addons: {apt: {packages: [cabal-install-1.24,libsdl1.2-dev], sources: [hvr-ghc]}}
90 addons: {apt: {packages: [cabal-install-1.24,libsdl1.2-dev], sources: [hvr-ghc]}}
91
91
92 # Use cabal-install-1.24 for stack solver to work
92 # Use cabal-install-1.24 for stack solver to work
@@ -114,10 +114,12 @@ matrix:
114 #- env: BUILD=cabal-new GHCVER=8.2.2
114 #- env: BUILD=cabal-new GHCVER=8.2.2
115 # addons: {apt: {packages: [cabal-install-2.0,ghc-8.2.2], sources: [hvr-ghc]}}
115 # addons: {apt: {packages: [cabal-install-2.0,ghc-8.2.2], sources: [hvr-ghc]}}
116
116
117+ # Using stack builds, cabal builds get terminated because the tests
118+ # take more than 10 minutes and it does not produce any output until the end.
117− - env: BUILD=cabal-new GHCVER=8.4.3 GHC_OPTIONS=""
119+ - env: BUILD=stack RESOLVER=lts-12 GHCVER=8.4.3
118 addons: {apt: {packages: [cabal-install-2.2,ghc-8.4.3], sources: [hvr-ghc]}}
120 addons: {apt: {packages: [cabal-install-2.2,ghc-8.4.3], sources: [hvr-ghc]}}
119
121
120− - env: BUILD=cabal-new GHCVER=8.4.3 GHC_OPTIONS="" CABAL_NEWBUILD_OPTIONS="--flags=streamk"
122+ - env: BUILD=stack RESOLVER=lts-12 GHCVER=8.4.3 GHC_OPTIONS="" STACK_BUILD_OPTIONS="--flag streamly:streamk"
121 addons: {apt: {packages: [cabal-install-2.2,ghc-8.4.3], sources: [hvr-ghc]}}
123 addons: {apt: {packages: [cabal-install-2.2,ghc-8.4.3], sources: [hvr-ghc]}}
122
124
123 - env: BUILD=cabal-new GHCVER=head GHC_OPTIONS=""
125 - env: BUILD=cabal-new GHCVER=head GHC_OPTIONS=""
@@ -151,7 +153,7 @@ matrix:
151 # For available options see hpc-coveralls docs.
153 # For available options see hpc-coveralls docs.
152 # --------------------------------------------------------------------------
154 # --------------------------------------------------------------------------
153
155
154− - env: BUILD=cabal COVERALLS_OPTIONS="--coverage-mode=StrictlyFullLines --exclude-dir=test test properties loops nested-loops parallel-loops" DISABLE_SDIST_BUILD=y DISABLE_BENCH=y
156+ - env: BUILD=cabal COVERALLS_OPTIONS="--coverage-mode=StrictlyFullLines --exclude-dir=test test properties loops nested-loops parallel-loops" GHC_OPTIONS="-DCOVERAGE_BUILD" DISABLE_SDIST_BUILD=y DISABLE_BENCH=y DISABLE_DOCS=y
155 addons: {apt: {packages: [cabal-install-2.0,ghc-8.2.2], sources: [hvr-ghc]}}
157 addons: {apt: {packages: [cabal-install-2.0,ghc-8.2.2], sources: [hvr-ghc]}}
156
158
157 # --------------------------------------------------------------------------
159 # --------------------------------------------------------------------------
test/Main.hs+71−66
@@ -14,7 +14,7 @@ import Data.Foldable (forM_, fold)
14import Data.List (sort)
14import Data.List (sort)
15
15
16import Data.IORef
16import Data.IORef
17−import Test.Hspec
17+import Test.Hspec as H
18
18
19import Streamly
19import Streamly
20import Streamly.Prelude ((.:), nil)
20import Streamly.Prelude ((.:), nil)
@@ -37,6 +37,76 @@ toListParallel = S.toList . wAsyncly
37
37
38main :: IO ()
38main :: IO ()
39main = hspec $ do
39main = hspec $ do
40+ parallelTests
41+
42+ describe "Nested parallel and serial compositions" $ do
43+ let t = timed
44+ p = wAsyncly
45+ s = serially
46+ {-
47+ -- This is not correct, the result can also be [4,4,8,0,8,0,2,2]
48+ -- because of parallelism of [8,0] and [8,0].
49+ it "Nest <|>, <>, <|> (1)" $
50+ let t = timed
51+ in toListSerial (
52+ ((t 8 <|> t 4) <> (t 2 <|> t 0))
53+ <|> ((t 8 <|> t 4) <> (t 2 <|> t 0)))
54+ `shouldReturn` ([4,4,8,8,0,0,2,2])
55+ -}
56+ it "Nest <|>, <>, <|> (2)" $
57+ (S.toList . wAsyncly) (
58+ s (p (t 4 <> t 8) <> p (t 1 <> t 2))
59+ <> s (p (t 4 <> t 8) <> p (t 1 <> t 2)))
60+ `shouldReturn` ([4,4,8,8,1,1,2,2])
61+ -- FIXME: These two keep failing intermittently on Mac OS X
62+ -- Need to examine and fix the tests.
63+ {-
64+ it "Nest <|>, <=>, <|> (1)" $
65+ let t = timed
66+ in toListSerial (
67+ ((t 8 <|> t 4) <=> (t 2 <|> t 0))
68+ <|> ((t 9 <|> t 4) <=> (t 2 <|> t 0)))
69+ `shouldReturn` ([4,4,0,0,8,2,9,2])
70+ it "Nest <|>, <=>, <|> (2)" $
71+ let t = timed
72+ in toListSerial (
73+ ((t 4 <|> t 8) <=> (t 1 <|> t 2))
74+ <|> ((t 4 <|> t 9) <=> (t 1 <|> t 2)))
75+ `shouldReturn` ([4,4,1,1,8,2,9,2])
76+ -}
77+ it "Nest <|>, <|>, <|>" $
78+ (S.toList . wAsyncly) (
79+ ((t 4 <> t 8) <> (t 0 <> t 2))
80+ <> ((t 4 <> t 8) <> (t 0 <> t 2)))
81+ `shouldReturn` ([0,0,2,2,4,4,8,8])
82+
83+ ---------------------------------------------------------------------------
84+ -- Semigroup/Monoidal Composition strict ordering checks
85+ ---------------------------------------------------------------------------
86+
87+ -- test both (<>) and mappend to make sure we are using correct instance
88+ -- for Monoid that is using the right version of semigroup. Instance
89+ -- deriving can cause us to pick wrong instances sometimes.
90+
91+ describe "WSerial interleaved (<>) ordering check" $ interleaveCheck wSerially (<>)
92+ describe "WSerial interleaved mappend ordering check" $ interleaveCheck wSerially mappend
93+
94+ -- describe "WAsync interleaved (<>) ordering check" $ interleaveCheck wAsyncly (<>)
95+ -- describe "WAsync interleaved mappend ordering check" $ interleaveCheck wAsyncly mappend
96+
97+ describe "Async (<>) time order check" $ parallelCheck asyncly (<>)
98+ describe "Async mappend time order check" $ parallelCheck asyncly mappend
99+
100+ -- XXX this keeps failing intermittently, need to investigate
101+ -- describe "WAsync (<>) time order check" $ parallelCheck wAsyncly (<>)
102+ -- describe "WAsync mappend time order check" $ parallelCheck wAsyncly mappend
103+
104+ describe "Parallel (<>) time order check" $ parallelCheck parallely (<>)
105+ describe "Parallel mappend time order check" $ parallelCheck parallely mappend
106+
107+
108+parallelTests :: SpecWith ()
109+parallelTests = H.parallel $ do
40 describe "Runners" $ do
110 describe "Runners" $ do
41 -- XXX move these to property tests
111 -- XXX move these to property tests
42 -- XXX use an IORef to store and check the side effects
112 -- XXX use an IORef to store and check the side effects
@@ -142,47 +212,6 @@ main = hspec $ do
142 , [1, 7, 4, 8, 2, 9, 5, 3, 6]
212 , [1, 7, 4, 8, 2, 9, 5, 3, 6]
143 ])
213 ])
144
214
145− describe "Nested parallel and serial compositions" $ do
146− let t = timed
147− p = wAsyncly
148− s = serially
149− {-
150− -- This is not correct, the result can also be [4,4,8,0,8,0,2,2]
151− -- because of parallelism of [8,0] and [8,0].
152− it "Nest <|>, <>, <|> (1)" $
153− let t = timed
154− in toListSerial (
155− ((t 8 <|> t 4) <> (t 2 <|> t 0))
156− <|> ((t 8 <|> t 4) <> (t 2 <|> t 0)))
157− `shouldReturn` ([4,4,8,8,0,0,2,2])
158− -}
159− it "Nest <|>, <>, <|> (2)" $
160− (S.toList . wAsyncly) (
161− s (p (t 4 <> t 8) <> p (t 1 <> t 2))
162− <> s (p (t 4 <> t 8) <> p (t 1 <> t 2)))
163− `shouldReturn` ([4,4,8,8,1,1,2,2])
164− -- FIXME: These two keep failing intermittently on Mac OS X
165− -- Need to examine and fix the tests.
166− {-
167− it "Nest <|>, <=>, <|> (1)" $
168− let t = timed
169− in toListSerial (
170− ((t 8 <|> t 4) <=> (t 2 <|> t 0))
171− <|> ((t 9 <|> t 4) <=> (t 2 <|> t 0)))
172− `shouldReturn` ([4,4,0,0,8,2,9,2])
173− it "Nest <|>, <=>, <|> (2)" $
174− let t = timed
175− in toListSerial (
176− ((t 4 <|> t 8) <=> (t 1 <|> t 2))
177− <|> ((t 4 <|> t 9) <=> (t 1 <|> t 2)))
178− `shouldReturn` ([4,4,1,1,8,2,9,2])
179− -}
180− it "Nest <|>, <|>, <|>" $
181− (S.toList . wAsyncly) (
182− ((t 4 <> t 8) <> (t 0 <> t 2))
183− <> ((t 4 <> t 8) <> (t 0 <> t 2)))
184− `shouldReturn` ([0,0,2,2,4,4,8,8])
185−
186 ---------------------------------------------------------------------------
215 ---------------------------------------------------------------------------
187 -- Monoidal composition recursion loops
216 -- Monoidal composition recursion loops
188 ---------------------------------------------------------------------------
217 ---------------------------------------------------------------------------
@@ -387,30 +416,6 @@ main = hspec $ do
387 -- Slower tests are at the end
416 -- Slower tests are at the end
388 ---------------------------------------------------------------------------
417 ---------------------------------------------------------------------------
389
418
390− ---------------------------------------------------------------------------
391− -- Semigroup/Monoidal Composition strict ordering checks
392− ---------------------------------------------------------------------------
393−
394− -- test both (<>) and mappend to make sure we are using correct instance
395− -- for Monoid that is using the right version of semigroup. Instance
396− -- deriving can cause us to pick wrong instances sometimes.
397−
398− describe "WSerial interleaved (<>) ordering check" $ interleaveCheck wSerially (<>)
399− describe "WSerial interleaved mappend ordering check" $ interleaveCheck wSerially mappend
400−
401− -- describe "WAsync interleaved (<>) ordering check" $ interleaveCheck wAsyncly (<>)
402− -- describe "WAsync interleaved mappend ordering check" $ interleaveCheck wAsyncly mappend
403−
404− describe "Async (<>) time order check" $ parallelCheck asyncly (<>)
405− describe "Async mappend time order check" $ parallelCheck asyncly mappend
406−
407− -- XXX this keeps failing intermittently, need to investigate
408− -- describe "WAsync (<>) time order check" $ parallelCheck wAsyncly (<>)
409− -- describe "WAsync mappend time order check" $ parallelCheck wAsyncly mappend
410−
411− describe "Parallel (<>) time order check" $ parallelCheck parallely (<>)
412− describe "Parallel mappend time order check" $ parallelCheck parallely mappend
413−
414 ---------------------------------------------------------------------------
419 ---------------------------------------------------------------------------
415 -- Thread limits
420 -- Thread limits
416 ---------------------------------------------------------------------------
421 ---------------------------------------------------------------------------
test/Prop.hs+11−4
@@ -15,11 +15,11 @@ import Data.List (sort, foldl', scanl', findIndices, findIndex, elemIndices,
15import Data.Maybe (mapMaybe)
15import Data.Maybe (mapMaybe)
16import GHC.Word (Word8)
16import GHC.Word (Word8)
17
17
18−import Test.Hspec.QuickCheck (prop)
18+import Test.Hspec.QuickCheck
19import Test.QuickCheck (counterexample, Property, withMaxSuccess)
19import Test.QuickCheck (counterexample, Property, withMaxSuccess)
20import Test.QuickCheck.Monadic (run, monadicIO, monitor, assert, PropertyM)
20import Test.QuickCheck.Monadic (run, monadicIO, monitor, assert, PropertyM)
21
21
22−import Test.Hspec
22+import Test.Hspec as H
23
23
24import Streamly
24import Streamly
25import Streamly.Prelude ((.:), nil)
25import Streamly.Prelude ((.:), nil)
@@ -677,7 +677,12 @@ constructWithIterate t = do
677 `shouldReturn` (take 100 $ iterate (+ 1) 0)
677 `shouldReturn` (take 100 $ iterate (+ 1) 0)
678
678
679main :: IO ()
679main :: IO ()
680−main = hspec $ do
680+main = hspec
681+ $ H.parallel
682+#ifdef COVERAGE_BUILD
683+ $ modifyMaxSuccess (const 10)
684+#endif
685+ $ do
681 let folded :: IsStream t => [a] -> t IO a
686 let folded :: IsStream t => [a] -> t IO a
682 folded = serially . (\xs ->
687 folded = serially . (\xs ->
683 case xs of
688 case xs of
@@ -690,7 +695,9 @@ main = hspec $ do
690 , t . maxRate 0
695 , t . maxRate 0
691 , t . maxRate (-1)
696 , t . maxRate (-1)
692 , t . maxBuffer 0
697 , t . maxBuffer 0
698+#ifndef COVERAGE_BUILD
693 , t . maxBuffer 1
699 , t . maxBuffer 1
700+#endif
694 , t . maxThreads 0
701 , t . maxThreads 0
695 , t . maxThreads 1
702 , t . maxThreads 1
696 , t . maxThreads (-1)
703 , t . maxThreads (-1)
@@ -714,7 +721,7 @@ main = hspec $ do
714 ++ [wAsyncly . maxBuffer (-1)]
721 ++ [wAsyncly . maxBuffer (-1)]
715 let aheadOps :: IsStream t => ((AheadT IO a -> t IO a) -> Spec) -> Spec
722 let aheadOps :: IsStream t => ((AheadT IO a -> t IO a) -> Spec) -> Spec
716 aheadOps = forM_ $ makeOps aheadly
723 aheadOps = forM_ $ makeOps aheadly
717− ++ [aheadly . maxRate 1000]
724+ ++ [aheadly . maxRate 10000]
718 ++ [aheadly . maxBuffer (-1)]
725 ++ [aheadly . maxBuffer (-1)]
719 let parallelOps :: IsStream t => ((ParallelT IO a -> t IO a) -> Spec) -> Spec
726 let parallelOps :: IsStream t => ((ParallelT IO a -> t IO a) -> Spec) -> Spec
720 parallelOps = forM_ $ makeOps parallely
727 parallelOps = forM_ $ makeOps parallely