Fix testcase T12903 on OS X
authorAlexander Vershilov <alexander.vershilov@gmail.com>
Tue, 13 Dec 2016 19:54:36 +0000 (14:54 -0500)
committerBen Gamari <ben@smart-cactus.org>
Tue, 13 Dec 2016 20:38:33 +0000 (15:38 -0500)
Old test used timeouts that leads to the various sporadic errors.
Tet was rewritten to not use timeouts.

Reviewers: austin, erikd, simonmar, bgamari

Reviewed By: simonmar

Subscribers: thomie

Differential Revision: https://phabricator.haskell.org/D2827

GHC Trac Issues: #12956

testsuite/tests/rts/T12903.hs
testsuite/tests/rts/all.T

index ddaf8b9..e4a8486 100644 (file)
@@ -1,10 +1,21 @@
 import Control.Concurrent
 import Control.Exception
+import System.IO
 import System.Posix
+import System.Posix.IO
 
 main = do
+  (pout1, pin1) <- createPipe
+  (pout2, _) <- createPipe
   pid <- forkProcess $ do
-           handle (\UserInterrupt{} -> putStrLn "caught")
-                  $ threadDelay 2000000
+           hdl <- fdToHandle pin1
+           hSetBuffering hdl LineBuffering
+           handle (\UserInterrupt{} -> hPutStrLn hdl "caught")
+                  $ do hPutStrLn hdl "registered"
+                       hdl2 <- fdToHandle pout2
+                       putStrLn =<< hGetLine hdl2
+  hdl <- fdToHandle pout1
+  hSetBuffering hdl LineBuffering
+  "registered" <- hGetLine hdl
   signalProcess sigINT pid
-  threadDelay 2000000
+  putStrLn =<< hGetLine hdl
index c44ec04..a645ad3 100644 (file)
@@ -376,9 +376,5 @@ test('T12497', [ unless(opsys('mingw32'), skip)
                ],
                run_command, ['$MAKE -s --no-print-directory T12497'])
 
-# Test is being skipped on darwin due to it's flakiness.
-# See 12956
-test('T12903', [when(opsys('mingw32'), skip),
-                when(opsys('darwin'), skip)],
-     compile_and_run, [''])
+test('T12903', [when(opsys('mingw32'), skip)], compile_and_run, [''])