diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2023-10-23 21:05:55 +0200 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2023-10-23 21:05:55 +0200 |
commit | 224366e2c668784952ab613c7640d7017ce60990 (patch) | |
tree | ebbad4d9d53119c6f1b0f74ada973efa8ac06a86 /src/Run.hs | |
parent | ff5c3f5a91e249694f3b76109027cf9d0c717a7c (diff) |
Flush command
Changelog: Add 'flush' command
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 |