chuchu 0.4.2 → 0.4.3
raw patch · 3 files changed
+62/−5 lines, 3 filesdep ~cmdargs
Dependency ranges changed: cmdargs
Files
- chuchu.cabal +14/−2
- src/Test/Chuchu.hs +5/−3
- tests/background_fail.hs +43/−0
chuchu.cabal view
@@ -1,5 +1,5 @@ name: chuchu-version: 0.4.2+version: 0.4.3 cabal-version: >= 1.8 build-type: Simple license: OtherLicense@@ -46,7 +46,7 @@ text >= 0.11 && < 0.12, transformers >= 0.3 && < 0.4, parsec >= 3.1 && < 3.2,- cmdargs >= 0.9 && < 0.10,+ cmdargs >= 0.9 && < 0.11, ansi-wl-pprint == 0.6.*, abacate >= 0.0 && < 0.1, monad-control >= 0.3 && < 0.4,@@ -136,6 +136,18 @@ Test-Suite should_fail type: exitcode-stdio-1.0 main-is: should_fail.hs+ hs-source-dirs: tests+ build-depends:+ base >= 4 && < 5,+ transformers >= 0.3 && < 0.4,+ chuchu,+ HUnit >= 1.2 && < 1.3+ extensions: OverloadedStrings+ ghc-options: -Wall++Test-Suite background_fail+ type: exitcode-stdio-1.0+ main-is: background_fail.hs hs-source-dirs: tests build-depends: base >= 4 && < 5,
src/Test/Chuchu.hs view
@@ -77,7 +77,7 @@ (chuchuMain, module Test.Chuchu.Types, module Test.Chuchu.Parser) where -import Control.Applicative ((<$>), Applicative((<*>)))+import Control.Applicative ((<$>)) import Control.Monad (unless) import Control.Monad.IO.Class (MonadIO(liftIO)) import Control.Monad.Trans.Class (lift)@@ -190,8 +190,10 @@ ExecutionPlan -> Execution m Bool processExecutionPlan (ExecutionPlan mbackground scenario) = do liftIO $ putStrLn "" -- empty line (TODO: move into OutputPrinter somehow)- (&&) <$> maybe (return True) (processBasicScenario BackgroundKind) mbackground- <*> processFeatureElement scenario+ mapShortCircuitM id+ [ maybe (return True) (processBasicScenario BackgroundKind) mbackground+ , processFeatureElement scenario+ ] ----------------------------------------------------------------------
+ tests/background_fail.hs view
@@ -0,0 +1,43 @@+{-# LANGUAGE OverloadedStrings #-}++module Main (main) where++import Control.Monad.IO.Class+import Control.Monad.Trans.State+import Data.IORef+import System.Environment+import System.Exit (exitWith, ExitCode(ExitSuccess, ExitFailure))+import Test.Chuchu+import qualified Control.Exception as E+++data Result = NothingExecd | JustBackground | AllSteps++type BackgroundFail = StateT (IORef Result) IO+++defs :: Chuchu BackgroundFail+defs = do+ let reached s = do+ v <- get+ liftIO (writeIORef v s)++ Given "that this step will fail" $ \() -> do+ reached JustBackground+ fail "..."++ Then "this step should not be executed" $ \() ->+ reached AllSteps++main :: IO ()+main =+ withArgs ["tests/data/background_fail.feature"] $ do+ v <- newIORef NothingExecd+ E.catch (chuchuMain defs (`evalStateT` v))+ (\exitExc -> let _ = exitExc `asTypeOf` ExitSuccess+ in return ())+ final <- readIORef v+ case final of+ NothingExecd -> exitWith (ExitFailure 40)+ JustBackground -> exitWith ExitSuccess+ AllSteps -> exitWith (ExitFailure 80)