diff options
author | Roman Smrž <roman.smrz@seznam.cz> | 2021-11-18 21:27:22 +0100 |
---|---|---|
committer | Roman Smrž <roman.smrz@seznam.cz> | 2021-11-18 21:27:22 +0100 |
commit | e30d876d4839ab70f655adf893e85b1b1312192c (patch) | |
tree | e1d6e3a3b9beafa899251541d27a185d891fc6ee /src/Main.hs | |
parent | 19dd575ae33801121b308c082bab70c3bed0a24e (diff) |
Show regex partern on expect failure
Diffstat (limited to 'src/Main.hs')
-rw-r--r-- | src/Main.hs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Main.hs b/src/Main.hs index fd62a3e..ca4ff8c 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -164,8 +164,8 @@ tryMatch re (x:xs) | Right (Just _) <- regexec re x = Just (x, xs) | otherwise = fmap (x:) <$> tryMatch re xs tryMatch _ [] = Nothing -expect :: Output -> Process -> Regex -> IO Bool -expect out p re = do +expect :: Output -> Process -> Regex -> Text -> IO Bool +expect out p re pat = do delay <- registerDelay 1000000 mbmatch <- atomically $ (Nothing <$ (check =<< readTVar delay)) <|> do line <- readTVar (procOutput p) @@ -179,7 +179,7 @@ expect out p re = do outLine out OutputMatch (Just $ procName p) line return True Nothing -> do - outLine out OutputMatchFail (Just $ procName p) $ T.pack "expect failed" + outLine out OutputMatchFail (Just $ procName p) $ T.pack "expect failed /" `T.append` pat `T.append` T.pack "/" return False send :: Process -> Text -> IO Bool @@ -219,9 +219,9 @@ runTest out tool test = do p <- getProcess net pname send p line - Expect pname regex -> do + Expect pname regex pat -> do p <- getProcess net pname - expect out p regex + expect out p regex pat Wait -> do outPrompt out $ T.pack "Waiting..." |