Skip to content

Commit 65a6078

Browse files
committed
save test option flags ; ignore stderr or stdout when it should be
1 parent 81974ad commit 65a6078

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

external-stg-interpreter/app/RunStgiTestsuite.hs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import System.Environment
1818
import Data.Maybe
1919
import Data.Set (Set)
2020
import qualified Data.Set as Set
21+
import qualified Data.Map as Map
2122
import Data.ByteString (ByteString)
2223
import qualified Data.ByteString.Char8 as BS8
2324
import 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+
113119
runTest :: Set FilePath -> FilePath -> IO TestResult
114120
runTest 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

ghc-wpc-testsuite-ci/ghc-9.2.7-testsuite.patch

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ index 81885ac6fb..17cd446607 100644
77
self.rootdirs = []
88

99
+ # Run only the runnable tests
10-
+ self.runnable_only = True
10+
+ self.runnable_only = False
1111
+
1212
# Run these tests only (run all tests if empty)
1313
self.run_only_some_tests = False
@@ -40,10 +40,13 @@ index 8b58084921..188a31971b 100644
4040
stdout_arg = in_testdir(name, 'run.stdout')
4141
if opts.combined_output:
4242
stderr_arg = subprocess.STDOUT # type: Union[int, Path]
43-
@@ -1739,6 +1749,10 @@ def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: str) ->
43+
@@ -1739,6 +1749,13 @@ def simple_run(name: TestName, way: WayName, prog: str, extra_run_opts: str) ->
4444
# run the command
4545
exit_code = runCmd(cmd, stdin_arg, stdout_arg, stderr_arg, opts.run_timeout_multiplier)
4646

47+
+ # save test opts
48+
+ in_testdir(name, 'run.opts').write_text(f'[("ignore_stdout",{opts.ignore_stdout}),("ignore_stderr",{opts.ignore_stderr})]')
49+
+
4750
+ # save exit code
4851
+ in_testdir(name, 'run.exitcode').write_text(str(exit_code))
4952
+ in_testdir(name, 'expected.exitcode').write_text(str(opts.exit_code))

0 commit comments

Comments
 (0)