Skip to content

Commit 279d65c

Browse files
committed
Tests: work around LazyHClose, these tests are not runnable concurrently
1 parent edeb0ab commit 279d65c

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

tests/LazyHClose.hs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
{-# LANGUAGE CPP #-}
2+
{- HLINT ignore "Use fewer imports" -}
3+
14
module LazyHClose (testSuite) where
25

36
import Control.Monad (void, forM_)
@@ -6,22 +9,31 @@ import Foreign.C.String (withCString)
69
import Foreign.ForeignPtr (finalizeForeignPtr)
710
import System.IO (openFile, openTempFile, hClose, hPutStrLn, IOMode(..))
811
import System.Posix.Internals (c_unlink)
9-
import Test.Tasty (TestTree, testGroup, withResource)
12+
import Test.Tasty (TestTree, withResource)
1013
import Test.Tasty.QuickCheck (testProperty, ioProperty)
1114

1215
import qualified Data.ByteString as S
1316
import qualified Data.ByteString.Char8 as S8
1417
import qualified Data.ByteString.Lazy as L
1518
import qualified Data.ByteString.Lazy.Char8 as L8
1619

20+
#if MIN_VERSION_tasty(1,5,4)
21+
import Test.Tasty (inOrderTestGroup)
22+
#else
23+
import Test.Tasty (testGroup)
24+
25+
inOrderTestGroup :: String -> [TestTree] -> TestTree
26+
inOrderTestGroup = testGroup
27+
#endif
28+
1729
n :: Int
1830
n = 1000
1931

2032
testSuite :: TestTree
2133
testSuite = withResource
2234
(do (fn, h) <- openTempFile "." "lazy-hclose-test.tmp"; hPutStrLn h "x"; hClose h; pure fn)
2335
removeFile $ \fn' ->
24-
testGroup "LazyHClose"
36+
inOrderTestGroup "LazyHClose"
2537
[ testProperty "Testing resource leaks for Strict.readFile" $ ioProperty $
2638
forM_ [1..n] $ const $ do
2739
fn <- fn'

0 commit comments

Comments
 (0)