Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Improved mkstemp test script

  • Loading branch information...
commit 59f6d08ed5ebc6adc1ecc7cea12a24d5b529f682 1 parent b5bf6f9
Jacob Stanley authored
Showing with 21 additions and 7 deletions.
  1. +21 −7 tests/mkstemp.hs
28 tests/mkstemp.hs
View
@@ -1,13 +1,27 @@
-import Control.Monad
-import System.PosixCompat
+import Control.Monad.Parallel
+import Data.List
+import System.Directory
import System.IO
+import System.PosixCompat
main :: IO ()
-main = replicateM_ 10 mktemp
+main = do
+ let n = 10000
+ hSetBuffering stdout NoBuffering
+
+ putStr $ "Creating " ++ show n ++ " temp files..."
+ xs <- replicateM n createTempFile
+ if length xs == n
+ then putStrLn "ok"
+ else putStrLn "FAIL"
+
+ putStr "Deleting temp files..."
+ mapM_ removeFile xs
+ putStrLn "ok"
-mktemp :: IO ()
-mktemp = do
+createTempFile :: IO FilePath
+createTempFile = do
(p,h) <- mkstemp "tempfileXXXXXXX"
- putStrLn $ "Created temp file: " ++ p
- hPutStrLn h "This is a temp file"
+ hPutStrLn h "this is a temporary file"
hClose h
+ return p
Please sign in to comment.
Something went wrong with that request. Please try again.