on master help sign in
Hide failing parallel tests behind a DEVBUILD.
425adcaPranay Sashank
test/Streamly/Test/Prelude/Common.hs+18−4
@@ -88,9 +88,13 @@ module Streamly.Test.Prelude.Common
88import Control.Applicative (ZipList(..), liftA2)
88import Control.Applicative (ZipList(..), liftA2)
89import Control.Exception (Exception, try)
89import Control.Exception (Exception, try)
90import Control.Concurrent (threadDelay)
90import Control.Concurrent (threadDelay)
91−import Control.Monad (replicateM, when)
91+import Control.Monad (replicateM)
92+#ifdef DEVBUILD
93+import Control.Monad (when)
94+#endif
92import Control.Monad.Catch (throwM, MonadThrow)
95import Control.Monad.Catch (throwM, MonadThrow)
93−import Data.IORef (IORef, modifyIORef', newIORef, readIORef, writeIORef)
96+import Data.IORef ( IORef, atomicModifyIORef', modifyIORef', newIORef
97+ , readIORef, writeIORef)
94import Data.List
98import Data.List
95 ( delete
99 ( delete
96 , deleteBy
100 , deleteBy
@@ -1398,7 +1402,8 @@ beforeProp t vec =
1398 run
1402 run
1399 $ S.drain . t
1403 $ S.drain . t
1400 $ S.before (writeIORef ioRef [0])
1404 $ S.before (writeIORef ioRef [0])
1401− $ S.mapM (\a -> modifyIORef' ioRef (++ [a]) >> return a)
1405+ $ S.mapM (\a -> do atomicModifyIORef' ioRef (\xs -> (xs ++ [a], ()))
1406+ return a)
1402 $ S.fromList vec
1407 $ S.fromList vec
1403 refValue <- run $ readIORef ioRef
1408 refValue <- run $ readIORef ioRef
1404 listEquals (==) (head refValue : sort (tail refValue)) (0:sort vec)
1409 listEquals (==) (head refValue : sort (tail refValue)) (0:sort vec)
@@ -1411,7 +1416,8 @@ afterProp t vec =
1411 run
1416 run
1412 $ S.drain . t
1417 $ S.drain . t
1413 $ S.after (modifyIORef' ioRef (0:))
1418 $ S.after (modifyIORef' ioRef (0:))
1414− $ S.mapM (\a -> modifyIORef' ioRef (a:) >> return a)
1419+ $ S.mapM (\a -> do atomicModifyIORef' ioRef (\xs -> (a:xs, ()))
1420+ return a)
1415 $ S.fromList vec
1421 $ S.fromList vec
1416 refValue <- run $ readIORef ioRef
1422 refValue <- run $ readIORef ioRef
1417 listEquals (==) (head refValue : sort (tail refValue)) (0:sort vec)
1423 listEquals (==) (head refValue : sort (tail refValue)) (0:sort vec)
@@ -1433,6 +1439,7 @@ bracketProp t vec =
1433 refValue <- run $ readIORef ioRef
1439 refValue <- run $ readIORef ioRef
1434 assert $ refValue == 1
1440 assert $ refValue == 1
1435
1441
1442+#ifdef DEVBUILD
1436bracketPartialStreamProp ::
1443bracketPartialStreamProp ::
1437 (IsStream t) => (t IO Int -> SerialT IO Int) -> [Int] -> Property
1444 (IsStream t) => (t IO Int -> SerialT IO Int) -> [Int] -> Property
1438bracketPartialStreamProp t vec =
1445bracketPartialStreamProp t vec =
@@ -1456,6 +1463,7 @@ bracketPartialStreamProp t vec =
1456 refValue <- run $ readIORef ioRef
1463 refValue <- run $ readIORef ioRef
1457 when (refValue /= 0 && refValue /= 3) $
1464 when (refValue /= 0 && refValue /= 3) $
1458 error $ "refValue == " ++ show refValue
1465 error $ "refValue == " ++ show refValue
1466+#endif
1459
1467
1460bracketExceptionProp ::
1468bracketExceptionProp ::
1461 (IsStream t, MonadThrow (t IO)
1469 (IsStream t, MonadThrow (t IO)
@@ -1493,6 +1501,7 @@ finallyProp t vec =
1493 refValue <- run $ readIORef ioRef
1501 refValue <- run $ readIORef ioRef
1494 assert $ refValue == 1
1502 assert $ refValue == 1
1495
1503
1504+#ifdef DEVBUILD
1496finallyPartialStreamProp ::
1505finallyPartialStreamProp ::
1497 (IsStream t) => (t IO Int -> SerialT IO Int) -> [Int] -> Property
1506 (IsStream t) => (t IO Int -> SerialT IO Int) -> [Int] -> Property
1498finallyPartialStreamProp t vec =
1507finallyPartialStreamProp t vec =
@@ -1514,6 +1523,7 @@ finallyPartialStreamProp t vec =
1514 refValue <- run $ readIORef ioRef
1523 refValue <- run $ readIORef ioRef
1515 when (refValue /= 0 && refValue /= 2) $
1524 when (refValue /= 0 && refValue /= 2) $
1516 error $ "refValue == " ++ show refValue
1525 error $ "refValue == " ++ show refValue
1526+#endif
1517
1527
1518finallyExceptionProp ::
1528finallyExceptionProp ::
1519 (IsStream t, MonadThrow (t IO)
1529 (IsStream t, MonadThrow (t IO)
@@ -1588,11 +1598,15 @@ exceptionOps desc t = do
1588 prop (desc <> " before") $ beforeProp t
1598 prop (desc <> " before") $ beforeProp t
1589 prop (desc <> " after") $ afterProp t
1599 prop (desc <> " after") $ afterProp t
1590 prop (desc <> " bracket end of stream") $ bracketProp t
1600 prop (desc <> " bracket end of stream") $ bracketProp t
1601+#ifdef DEVBUILD
1591 prop (desc <> " bracket partial stream") $ bracketPartialStreamProp t
1602 prop (desc <> " bracket partial stream") $ bracketPartialStreamProp t
1603+#endif
1592 prop (desc <> " bracket exception in stream") $ bracketExceptionProp t
1604 prop (desc <> " bracket exception in stream") $ bracketExceptionProp t
1593 prop (desc <> " onException") $ onExceptionProp t
1605 prop (desc <> " onException") $ onExceptionProp t
1594 prop (desc <> " finally end of stream") $ finallyProp t
1606 prop (desc <> " finally end of stream") $ finallyProp t
1607+#ifdef DEVBUILD
1595 prop (desc <> " finally partial stream") $ finallyPartialStreamProp t
1608 prop (desc <> " finally partial stream") $ finallyPartialStreamProp t
1609+#endif
1596 prop (desc <> " finally exception in stream") $ finallyExceptionProp t
1610 prop (desc <> " finally exception in stream") $ finallyExceptionProp t
1597 prop (desc <> " handle") $ handleProp t
1611 prop (desc <> " handle") $ handleProp t
1598
1612