summaryrefslogtreecommitdiff
path: root/src/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main.hs')
-rw-r--r--src/Main.hs15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/Main.hs b/src/Main.hs
index e062dee..5e1e7b2 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -267,8 +267,8 @@ tryMatch re (x:xs) | Right (Just (_, _, _, capture)) <- regexec re x = Just ((x,
| otherwise = fmap (x:) <$> tryMatch re xs
tryMatch _ [] = Nothing
-expect :: Process -> Regex -> Text -> [VarName] -> TestRun ()
-expect p re pat vars = do
+expect :: SourceLine -> Process -> Regex -> [VarName] -> TestRun ()
+expect (SourceLine sline) p re vars = do
timeout <- asks $ optTimeout . teOptions
delay <- liftIO $ registerDelay $ ceiling $ 1000000 * timeout
mbmatch <- atomicallyTest $ (Nothing <$ (check =<< readTVar delay)) <|> do
@@ -281,19 +281,19 @@ expect p re pat vars = do
case mbmatch of
Just (line, capture) -> do
when (length vars /= length capture) $ do
- outLine OutputMatchFail (Just $ procName p) $ T.pack "mismatched number of capture variables /" `T.append` pat `T.append` T.pack "/"
+ outLine OutputMatchFail (Just $ procName p) $ T.pack "mismatched number of capture variables on " `T.append` sline
throwError ()
forM_ vars $ \name -> do
cur <- gets (lookup name . tsVars)
when (isJust cur) $ do
- outLine OutputMatchFail (Just $ procName p) $ T.pack "variable already exists: '" `T.append` textVarName name `T.append` T.pack "'"
+ outLine OutputMatchFail (Just $ procName p) $ T.pack "variable '" `T.append` textVarName name `T.append` T.pack "' already exists on " `T.append` sline
throwError ()
modify $ \s -> s { tsVars = zip vars capture ++ tsVars s }
outLine OutputMatch (Just $ procName p) line
Nothing -> do
- outLine OutputMatchFail (Just $ procName p) $ T.pack "expect failed /" `T.append` pat `T.append` T.pack "/"
+ outLine OutputMatchFail (Just $ procName p) $ T.pack "expect failed on " `T.append` sline
throwError ()
allM :: Monad m => [a] -> (a -> m Bool) -> m Bool
@@ -335,11 +335,10 @@ runTest out opts test = do
line <- eval expr
send p line
- Expect pname expr@(Regex ps) captures -> do
+ Expect line pname expr captures -> do
p <- getProcess net pname
regex <- eval expr
- pat <- eval (Concat ps)
- expect p regex pat captures
+ expect line p regex captures
Wait -> do
outPrompt $ T.pack "Waiting..."