summaryrefslogtreecommitdiff
path: root/libraries/base/tests/T8089.hs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/base/tests/T8089.hs')
-rw-r--r--libraries/base/tests/T8089.hs32
1 files changed, 32 insertions, 0 deletions
diff --git a/libraries/base/tests/T8089.hs b/libraries/base/tests/T8089.hs
new file mode 100644
index 0000000000..2b98f94198
--- /dev/null
+++ b/libraries/base/tests/T8089.hs
@@ -0,0 +1,32 @@
+import Control.Applicative
+import Control.Concurrent
+import Control.Exception
+import Control.Monad
+import System.Environment
+import System.Exit
+import System.Process
+import System.Timeout
+
+testLoop :: Int -> IO (Maybe a) -> IO (Maybe a)
+testLoop 0 _ = return Nothing
+testLoop i act = do
+ result <- act
+ case result of
+ Nothing -> threadDelay 100000 >> testLoop (i-1) act
+ Just x -> return (Just x)
+
+
+forkTestChild :: IO ()
+forkTestChild = do
+ (_, _, _, hnd) <- createProcess (proc "./T8089" ["test"])
+ result <- testLoop 50 $ getProcessExitCode hnd
+ case result of
+ Nothing -> terminateProcess hnd >> exitSuccess
+ Just exitCode -> exitWith exitCode
+
+main :: IO ()
+main = do
+ numArgs <- length <$> getArgs
+ if numArgs > 0
+ then threadDelay maxBound
+ else forkTestChild