packages feed

chuchu 0.1.0.0 → 0.1.1

raw patch · 3 files changed

+80/−8 lines, 3 filesdep +ansi-wl-pprintnew-uploaderPVP ok

version bump matches the API change (PVP)

Dependencies added: ansi-wl-pprint

API changes (from Hackage documentation)

Files

Test/Chuchu.hs view
@@ -84,6 +84,9 @@ import System.Exit import System.IO +-- text+import qualified Data.Text as T+ -- transformers import Control.Monad.IO.Class import Control.Monad.Trans.Class@@ -96,6 +99,9 @@ -- cmdargs import System.Console.CmdArgs +-- ansi-wl-pprint+import qualified Text.PrettyPrint.ANSI.Leijen as D+ -- abacate import Language.Abacate hiding (StepKeyword (..)) @@ -123,16 +129,40 @@  type CM m a = ReaderT (Parser (m ())) m a + processAbacate :: MonadIO m => Abacate -> CM m Bool processAbacate feature   = do+    -- Print feature description.+    putDoc $ describeAbacate feature++    -- Execute features.     bCode       <- case fBackground feature of         Nothing -> return True-        Just background -> processBasicScenario background+        Just background -> processBasicScenario BackgroundKind background     feCode <- processFeatureElements $ fFeatureElements feature     return $ bCode && feCode +-- | Print a 'D.Doc' describing what we're currently processing.+putDoc :: MonadIO m => D.Doc -> CM m ()+putDoc = liftIO . D.putDoc . (D.<> D.linebreak)++-- | Creates a pretty description of the feature.+describeAbacate :: Abacate -> D.Doc+describeAbacate feature =+  (if null (fTags feature) then id else (describeTags (fTags feature) D.<$>)) $+  D.white (t2d (fHeader feature))++-- | Creates a vertical list of tags.+describeTags :: Tags -> D.Doc+describeTags = D.vsep . map (D.dullcyan . ("@" D.<>) . t2d)++-- | Same as 'D.text' but using 'T.Text'.+t2d :: T.Text -> D.Doc+t2d = D.text . T.unpack++ processFeatureElements :: MonadIO m => FeatureElements -> CM m Bool processFeatureElements featureElements   = do@@ -143,11 +173,31 @@ processFeatureElement (FESO _)   = liftIO (hPutStrLn stderr "Scenario Outlines are not supported yet.")     >> return False-processFeatureElement (FES sc) = processBasicScenario $ scBasicScenario sc+processFeatureElement (FES sc) =+  processBasicScenario (ScenarioKind $ scTags sc) $ scBasicScenario sc -processBasicScenario :: MonadIO m => BasicScenario -> CM m Bool-processBasicScenario = processSteps . bsSteps +data BasicScenarioKind = BackgroundKind | ScenarioKind Tags++processBasicScenario :: MonadIO m => BasicScenarioKind -> BasicScenario -> CM m Bool+processBasicScenario kind scenario = do+  putDoc $ describeBasicScenario kind scenario+  processSteps (bsSteps scenario)++-- | Creates a pretty description of the basic scenario's header.+describeBasicScenario :: BasicScenarioKind -> BasicScenario -> D.Doc+describeBasicScenario kind scenario =+  D.indent 2 $+  prettyTags kind $+  D.bold ((describeBasicScenarioKind kind) D.<+> t2d (bsName scenario))+    where describeBasicScenarioKind BackgroundKind   = "Background:"+          describeBasicScenarioKind (ScenarioKind _) = "Scenario:"++          prettyTags BackgroundKind      = id+          prettyTags (ScenarioKind tags) = (describeTags tags D.<$>)+++ processSteps :: MonadIO m => Steps -> CM m Bool processSteps steps   = do@@ -161,6 +211,7 @@     case parse cc "processStep" $ stBody step of       Left e         -> do+          putDoc $ describeStep UnknownStep step           liftIO             $ hPutStrLn stderr             $ "The step "@@ -168,7 +219,23 @@               ++ " doesn't match any step definitions I know."               ++ show e           return False-      Right m -> lift m >> return True+      Right m -> do+        -- TODO: Catch failures and treat them nicely.+        putDoc $ describeStep SuccessfulStep step+        lift m+        return True++data StepResult = SuccessfulStep | UnknownStep++-- | Pretty-prints a step that has already finished executing.+describeStep :: StepResult -> Step -> D.Doc+describeStep result step =+  D.indent 4 $+  color result (D.text (show $ stStepKeyword step) D.<+> t2d (stBody step))+    where+      color SuccessfulStep = D.green+      color UnknownStep    = D.yellow+  data Options   = Options {file_ :: FilePath}
Test/Chuchu/Types.hs view
@@ -13,7 +13,7 @@  -- base import Control.Applicative hiding ((<|>))-import GHC.Exts+import Data.String  -- parsec import Text.Parsec
chuchu.cabal view
@@ -1,5 +1,5 @@ name: chuchu-version: 0.1.0.0+version: 0.1.1 cabal-version: >= 1.8 build-type: Simple license: OtherLicense@@ -22,6 +22,10 @@   tests/data/calculator.feature,   tests/data/prefix.feature +source-repository head+  type:     git+  location: git://github.com/marcotmarcot/chuchu.git+ library   exposed-modules:     Test.Chuchu,@@ -36,8 +40,9 @@     transformers >= 0.3 && < 0.4,     parsec >= 3.1 && < 3.2,     cmdargs >= 0.9 && < 0.10,+    ansi-wl-pprint == 0.6.*,     abacate >= 0.0 && < 0.1-  extensions: DeriveDataTypeable, GADTs, GeneralizedNewtypeDeriving+  extensions: DeriveDataTypeable, GADTs, GeneralizedNewtypeDeriving, OverloadedStrings   ghc-options: -Wall  Test-Suite environment