@@ -3,9 +3,11 @@ module Main (main) where
33import Control.Monad (void )
44import Data.ByteString.Lazy qualified as LBS
55import Data.Int (Int64 )
6+ import Data.Maybe (fromMaybe )
7+ import GHC.IO.Exception (ExitCode (ExitFailure ))
68import System.Directory (makeAbsolute )
79import System.FilePath (takeFileName , (<.>) , (</>) )
8- import System.IO (Handle , hClose )
10+ import System.IO (Handle , hClose , hPrint )
911import System.IO.Temp (withSystemTempFile )
1012import System.Timeout (timeout )
1113import Test.Tasty
@@ -94,8 +96,9 @@ amExecutionTests allExamples =
9496 $ executionOfExample " am" (makeAMOptions Run ) <$> allExamples
9597
9698executionOfExample :: String -> (FilePath -> Options ) -> String -> TestTree
97- executionOfExample tag = goldenOf (Just 10000 ) (" execution" <.> tag <.> " out" ) $ \ handle ->
98- timeout 300000 . mainFuncWithOptions handle
99+ executionOfExample tag = goldenOf (Just 10000 ) (" execution" <.> tag <.> " out" ) $ \ handle opt -> do
100+ exitCode <- timeoutWithExitCode 300000 $ mainFuncWithOptions handle opt
101+ hPrint handle exitCode
99102
100103goldenOf :: Maybe Int64 -> String -> (Handle -> Options -> IO a ) -> (FilePath -> Options ) -> String -> TestTree
101104goldenOf maySize tag f optionBuilder s =
@@ -125,3 +128,8 @@ getExampleDir = makeAbsolute "examples"
125128
126129gitDiff :: FilePath -> FilePath -> [String ]
127130gitDiff ref new = [" git" , " diff" , ref, new]
131+
132+ timeoutWithExitCode :: Int -> IO ExitCode -> IO ExitCode
133+ timeoutWithExitCode n = fmap (fromMaybe timeOutExitCode) . timeout n
134+ where
135+ timeOutExitCode = ExitFailure 124
0 commit comments