From e30d876d4839ab70f655adf893e85b1b1312192c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Thu, 18 Nov 2021 21:27:22 +0100 Subject: Show regex partern on expect failure --- src/Main.hs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/Main.hs') 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..." -- cgit v1.2.3