@@ -18,6 +18,7 @@ import System.Environment
1818import Data.Maybe
1919import Data.Set (Set )
2020import qualified Data.Set as Set
21+ import qualified Data.Map as Map
2122import Data.ByteString (ByteString )
2223import qualified Data.ByteString.Char8 as BS8
2324import Text.PrettyPrint.ANSI.Leijen hiding ((</>) , (<$>) )
@@ -110,11 +111,17 @@ runTestProcess path cmd args input = do
110111 errData <- BS8. readFile stderrPath
111112 pure (exitCode, outData, errData)
112113
114+ readTestOpts :: FilePath -> IO (Bool , Bool )
115+ readTestOpts optsPath = do
116+ opts <- Map. fromList . read <$> readFile optsPath
117+ pure . fromJust $ (,) <$> Map. lookup " ignore_stdout" opts <*> Map. lookup " ignore_stderr" opts
118+ 113119runTest :: Set FilePath -> FilePath -> IO TestResult
114120runTest skipSet stderrPath = do
115121 let stdoutPath = stderrPath -<.> " .stdout"
116122 stdinPath = stderrPath -<.> " .stdin"
117123 argsPath = stderrPath -<.> " .args"
124+ optsPath = stderrPath -<.> " .opts"
118125 exitcodePath = stderrPath -<.> " .exitcode"
119126 testName = takeFileName . dropExtension $ dropExtension stderrPath
120127 testDir = takeDirectory stderrPath
@@ -145,6 +152,7 @@ runTest skipSet stderrPath = do
145152 False -> pure " "
146153 True -> BS8. readFile stdinPath
147154
155+ (ignoreStdout, ignoreStderr) <- readTestOpts optsPath
148156 expectedStderr <- BS8. readFile stderrPath
149157 expectedStdout <- BS8. readFile stdoutPath
150158 expectedExitCode <- (read <$> readFile exitcodePath) >>= \ case
@@ -161,7 +169,7 @@ runTest skipSet stderrPath = do
161169 case mResult of
162170 Nothing -> report $ Timeout ghcstgappPath
163171 Just (exitCode, out, err) -> do
164- if expectedExitCode == exitCode && expectedStdout == out && expectedStderr == err
172+ if expectedExitCode == exitCode && ( expectedStdout == out || ignoreStdout) && ( expectedStderr == err|| ignoreStderr)
165173 then report $ OK ghcstgappPath
166174 else report $ Fail ghcstgappPath (expectedExitCode, exitCode) (expectedStdout, out) (expectedStderr, err)
167175
0 commit comments