Ticket #5891: ghc-race.hs

File ghc-race.hs, 533 bytes (added by akio, 2 years ago)

program to reproduce

Line 
1import Control.Monad
2import System.Directory
3import System.Process
4import Text.Printf
5
6main = replicateM_ 10 test
7
8ghc :: String
9ghc = "ghc"
10
11test :: IO ()
12test = do
13    createDirectory "src"
14    forM_ [1..n] $ \i ->
15        writeFile (printf "src/M%d.hs" i) $ printf "module M%d where" i
16    handles <- forM [1..n] $ \i ->
17        runCommand $ printf "%s -c -isrc -odir obj M%i.hs" ghc i
18    mapM_ waitForProcess handles
19    removeDirectoryRecursive "src"
20    removeDirectoryRecursive "obj"
21    where
22        n :: Int
23        n = 2