@@ -8,11 +8,11 @@ module Tests.Utils
88 , withTempFile
99 ) where
1010
11- import Control.Exception (SomeException , bracket , bracket_ , evaluate , try )
12- import Control.Monad (when , unless )
11+ import Control.Exception (SomeException , bracket_ , evaluate , try )
12+ import Control.Monad (when )
13+ import System.IO.Temp (withSystemTempFile )
1314import GHC.IO.Handle.Internals (withHandle )
14- import System.Directory (removeFile )
15- import System.IO (Handle , hClose , hFlush , hIsOpen , hIsClosed , hIsWritable , openTempFile )
15+ import System.IO (Handle , hFlush , hIsOpen , hIsWritable )
1616import Test.QuickCheck (Property , ioProperty , property , (===) , counterexample )
1717
1818-- Ensure that two potentially bottom values (in the sense of crashing
@@ -31,12 +31,7 @@ infix 4 =^=
3131{-# NOINLINE (=^=) #-}
3232
3333withTempFile :: (FilePath -> Handle -> IO a ) -> IO a
34- withTempFile = bracket (openTempFile " ." " crashy.txt" ) cleanupTemp . uncurry
35- where
36- cleanupTemp (path,h) = do
37- closed <- hIsClosed h
38- unless closed $ hClose h
39- removeFile path
34+ withTempFile = withSystemTempFile " crashy.txt"
4035
4136withRedirect :: Handle -> Handle -> IO a -> IO a
4237withRedirect tmp h = bracket_ swap swap
0 commit comments