Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
19 lines (14 sloc) 476 Bytes
module TestUtil where
import Test.HUnit
import System.Directory
import Control.Monad
import Control.Exception
setupFile :: FilePath -> IO String
setupFile fn =
doesFileExist fn >>=
flip when (assertFailure ("setupFile: (" ++ fn ++ ") already exists!")) >>
return fn
teardownFile :: String -> IO ()
teardownFile fn = doesFileExist fn >>= flip when (removeFile fn)
withoutFile :: String -> (String -> IO a) -> IO a
withoutFile fn = bracket (setupFile fn) teardownFile
Jump to Line
Something went wrong with that request. Please try again.