Commit 628d36c7 authored by Jan Rasmus Tikovsky 's avatar Jan Rasmus Tikovsky
Browse files

TestFrontend: Print expected but missing warnings and failure messages for test cases

parent 38cb35e0
......@@ -35,7 +35,7 @@ import Curry.Base.Message (Message, message, ppMessages, ppError)
import Curry.Base.Monad (CYIO, runCYIO)
import Curry.Base.Pretty (text)
import qualified CompilerOpts as CO ( Options (..), WarnOpts (..)
, WarnFlag (..), Verbosity (VerbQuiet)
, Verbosity (VerbQuiet)
, defaultOptions, defaultWarnOpts)
import CurryBuilder (buildCurry)
......@@ -50,11 +50,7 @@ runSecure act = runCYIO act `E.catch` handler
runTest :: CO.Options -> String -> [String] -> IO Progress
runTest opts test [] = passOrFail <$> runSecure (buildCurry opts' test)
where
wOpts = CO.optWarnOpts opts
wFlags = CO.WarnUnusedBindings : CO.wnWarnFlags wOpts
opts' = opts { CO.optForce = True
, CO.optWarnOpts = wOpts { CO.wnWarnFlags = wFlags }
}
opts' = opts { CO.optForce = True }
passOrFail = Finished . either fail pass
fail msgs
| null msgs = Pass
......@@ -62,17 +58,13 @@ runTest opts test [] = passOrFail <$> runSecure (buildCurry opts' test)
pass _ = Pass
runTest opts test errorMsgs = catchE <$> runSecure (buildCurry opts' test)
where
wOpts = CO.optWarnOpts opts
wFlags = CO.WarnUnusedBindings : CO.wnWarnFlags wOpts
opts' = opts { CO.optForce = True
, CO.optWarnOpts = wOpts { CO.wnWarnFlags = wFlags }
}
catchE = Finished . either pass fail
pass msgs = let errorStr = showMessages msgs
in if all (`isInfixOf` errorStr) errorMsgs
then Pass
else Fail $ "Expected warning/failure did not occur: "
++ errorStr
opts' = opts { CO.optForce = True }
catchE = Finished . either pass fail
pass msgs = let errorStr = showMessages msgs
leftOverMsgs = filter (not . flip isInfixOf errorStr) errorMsgs
in if null leftOverMsgs
then Pass
else Fail $ "Expected warnings/failures did not occur: " ++ unwords leftOverMsgs
fail = pass . snd
showMessages :: [Message] -> String
......
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