diff options
Diffstat (limited to 'src/Run.hs')
-rw-r--r-- | src/Run.hs | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -10,6 +10,7 @@ import Control.Monad import Control.Monad.Except import Control.Monad.Reader +import Data.Either import Data.Map qualified as M import Data.Maybe import Data.Set qualified as S @@ -151,6 +152,10 @@ evalSteps = mapM_ $ \case p <- eval pname expect line p expr captures $ evalSteps inner + Flush pname expr -> do + p <- eval pname + flush p expr + Guard line expr -> do testStepGuard line expr @@ -304,6 +309,14 @@ expect (SourceLine sline) p expr tvars inner = do Nothing -> exprFailed (T.pack "expect") (SourceLine sline) (Just $ procName p) expr +flush :: Process -> Maybe (Expr Regex) -> TestRun () +flush p mbexpr = do + mbre <- sequence $ fmap eval mbexpr + atomicallyTest $ do + writeTVar (procOutput p) =<< case mbre of + Nothing -> return [] + Just re -> filter (isLeft . regexMatch re) <$> readTVar (procOutput p) + testStepGuard :: SourceLine -> Expr Bool -> TestRun () testStepGuard sline expr = do x <- eval expr |