Verified Commit 59f97422 authored by Camil Staps's avatar Camil Staps 🚀

Resolve #9: set non-zero return code on failure

parent 2d807b95
implementation module Gast.CommandLine implementation module Gast.CommandLine
import StdBool
from StdFunc import flip, o from StdFunc import flip, o
import StdList import StdList
import StdString import StdString
...@@ -57,9 +58,7 @@ exposeProperties printopts globopts ps w ...@@ -57,9 +58,7 @@ exposeProperties printopts globopts ps w
, p , p
) \\ r <- rs, p <- ps | r.TestRun.name == testname p] ) \\ r <- rs, p <- ps | r.TestRun.name == testname p]
# ps = filter (\p -> not (isMember (testname p) opts.test_options.skip)) ps # ps = filter (\p -> not (isMember (testname p) opts.test_options.skip)) ps
# events = [Test (globopts ++ opts.global_options ++ getOptions p) p \\ p <- ps] # (io,w) = seqSt (test opts.global_print_options opts.global_options) ps io w
# outputs = [printEvents (toPrintConfig (printopts ++ opts.global_print_options ++ getPrintOptions p)) es \\ es <- events & p <- ps]
# io = foldl (<<<) io $ flatten outputs
# (_,w) = fclose io w # (_,w) = fclose io w
= w = w
where where
...@@ -71,6 +70,29 @@ where ...@@ -71,6 +70,29 @@ where
# w = setReturnCode 1 w # w = setReturnCode 1 w
= w = w
// Specialized for the type of `test`
seqSt :: !(a .st1 -> .(.st2 -> .(.st1,.st2))) ![a] !.st1 !.st2 -> .(!.st1, !.st2)
seqSt f [x:xs] st1 st2
# (st1,st2) = f x st1 st2
# (st1,st2) = seqSt f xs st1 st2
= (st1,st2)
seqSt _ [] st1 st2 = (st1, st2)
test :: ![PrintOption] ![Testoption] !p !*File !*World -> *(!*File, !*World) | getOptions, getPrintOptions, Testable p
test popts opts p io w
# events = Test (globopts ++ opts ++ getOptions p) p
= stream (toPrintConfig (printopts ++ popts ++ getPrintOptions p)) events io w
where
stream :: !PrintConfig ![GastEvent] !*File !*World -> *(!*File, !*World)
stream pc [ge:ges] io w
# io = foldl (<<<) io $ printEvents pc [ge]
# w = case ge of
GE_TestFinished _ {resultType=CounterExpls _ _ _} _ _ -> setReturnCode 1 w
GE_TestFinished _ {resultType=Undefined _} _ _ -> setReturnCode 1 w
_ -> w
= stream pc ges io w
stream _ [] io w = (io,w)
optionDescription :: Option Options optionDescription :: Option Options
optionDescription = WithHelp True $ Options optionDescription = WithHelp True $ Options
[ Shorthand "-O" "--option" $ AddHelpLines [ Shorthand "-O" "--option" $ AddHelpLines
......
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