Commit d0cf8f1a authored by thomie's avatar thomie

Testsuite: simplify T8089 (#8089)

The previous implementation wasn't working for the `ghci` test way,
causing a fulltest failure.

Differential Revision:
parent 2f18b197
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
main = threadDelay maxBound
......@@ -178,5 +178,16 @@ test('T9395', normal, compile_and_run, [''])
test('T9532', omit_ways(['debug']), compile_and_run, [''])
test('T9586', normal, compile, [''])
test('T9681', normal, compile_fail, [''])
test('T8089', normal, compile_and_run, [''])
# Test no runtime crash. Report success and kill with `timeout` (exit code 99)
# after a few seconds. From
# "I used a fairly conservative timeout. IF there is a regression it will
# crash as soon as the timeout's C call is done. The tricky bit is
# guesstimating how much time it needs to run to guarantee it's reached the
# C call.
# Probably something like 1s is already enough, but I don't know enough to
# make an educated guess how long it needs to be guaranteed to reach the C
# call."
test('T8089', [exit_code(99), run_timeout_multiplier(0.01)],
compile_and_run, [''])
test('T9826',normal, compile_and_run,[''])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment