summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-02-25 22:58:14 +0100
committerPéter Diviánszky <divipp@gmail.com>2016-02-25 22:58:31 +0100
commit4017c18b6f9779d224effa6e83c7940857e1a1c9 (patch)
tree3f6f0a6f7359354bca04a8a4572d3da22edba56d /test
parentd5ab21e43e7525bb08c3eef8cfe7431889bb876e (diff)
better info handling
Diffstat (limited to 'test')
-rw-r--r--test/runTests.hs30
1 files changed, 15 insertions, 15 deletions
diff --git a/test/runTests.hs b/test/runTests.hs
index a9fb4e7f..299d5ad0 100644
--- a/test/runTests.hs
+++ b/test/runTests.hs
@@ -7,7 +7,7 @@ module Main where
7 7
8import Data.Char 8import Data.Char
9import Data.List 9import Data.List
10import Data.Either 10--import Data.Either
11import Data.Time.Clock 11import Data.Time.Clock
12import Data.Algorithm.Patience 12import Data.Algorithm.Patience
13import Control.Applicative 13import Control.Applicative
@@ -145,7 +145,7 @@ main = do
145 145
146 putStrLn $ "------------------------------------ Running " ++ show (length testSet) ++ " tests" 146 putStrLn $ "------------------------------------ Running " ++ show (length testSet) ++ " tests"
147 147
148 (Right resultDiffs, _) 148 resultDiffs
149 <- runMM (ioFetch [".", testDataPath]) 149 <- runMM (ioFetch [".", testDataPath])
150 $ forM (zip [1..] testSet) $ doTest cfg 150 $ forM (zip [1..] testSet) $ doTest cfg
151 151
@@ -186,7 +186,7 @@ doTest Config{..} (i, fn) = do
186 liftIO $ putStr $ pa ++ " " ++ mn ++ " " ++ concat exts ++ " " 186 liftIO $ putStr $ pa ++ " " ++ mn ++ " " ++ concat exts ++ " "
187 (runtime, res) <- mapMMT (timeOut cfgTimeout $ Left ("!Timed Out", TimedOut)) 187 (runtime, res) <- mapMMT (timeOut cfgTimeout $ Left ("!Timed Out", TimedOut))
188 $ catchErr (\e -> return $ Left (tab "!Crashed" e, ErrorCatched)) 188 $ catchErr (\e -> return $ Left (tab "!Crashed" e, ErrorCatched))
189 $ liftIO . evaluate =<< (force <$> action) 189 $ liftIO . evaluate =<< (force . f <$> getMain)
190 liftIO $ putStr $ "(" ++ showTime runtime ++ ")" ++ " " 190 liftIO $ putStr $ "(" ++ showTime runtime ++ ")" ++ " "
191 (msg, result) <- case res of 191 (msg, result) <- case res of
192 Left x -> return x 192 Left x -> return x
@@ -197,22 +197,22 @@ doTest Config{..} (i, fn) = do
197 (splitMPath -> (pa, mn', mn), reverse -> exts) = splitExtensions' $ dropExtension fn 197 (splitMPath -> (pa, mn', mn), reverse -> exts) = splitExtensions' $ dropExtension fn
198 198
199 getMain = do 199 getMain = do
200 r@(fname, x, _) <- local (const $ ioFetch [pa]) $ getDef (mn' ++ concat exts ++ ".lc") "main" Nothing 200 (is, res) <- local (const $ ioFetch [pa]) $ getDef (mn' ++ concat exts ++ ".lc") "main" Nothing
201 when (isRight x) $ removeFromCache fname 201 (,) is <$> case res of
202 return r 202 Left err -> return $ Left err
203 203 Right (fname, x@Left{}) -> return $ Right (fname, x)
204 action = f <$> (Right <$> getMain) `catchMM` (\e is -> return $ Left (e, is)) 204 Right (fname, x@Right{}) -> Right (fname, x) <$ removeFromCache fname
205 205
206 f | not $ isReject fn = \case 206 f (i, e) | not $ isReject fn = case e of
207 Left (e, i) -> Left (unlines $ tab "!Failed" e: listTraceInfos i, Failed) 207 Left e -> Left (unlines $ tab "!Failed" e: listTraceInfos i, Failed)
208 Right (fname, Left e, i) -> Right ("typechecked module" , unlines $ e: listAllInfos i) 208 Right (fname, Left e) -> Right ("typechecked module" , unlines $ e: listAllInfos i)
209 Right (fname, Right (e, te), force -> i) 209 Right (fname, Right (e, te))
210 | te == outputType -> Right ("compiled pipeline", prettyShowUnlines $ compilePipeline OpenGL33 (e, te)) 210 | te == outputType -> Right ("compiled pipeline", prettyShowUnlines $ compilePipeline OpenGL33 (e, te))
211 | e == trueExp -> Right ("reducted main", ppShow $ unfixlabel e) 211 | e == trueExp -> Right ("reducted main", ppShow $ unfixlabel e)
212 | te == boolType -> Left (tab "!Failed" $ "main should be True but it is \n" ++ ppShow e, Failed) 212 | te == boolType -> Left (tab "!Failed" $ "main should be True but it is \n" ++ ppShow e, Failed)
213 | otherwise -> Right ("reduced main " ++ ppShow te, ppShow e) 213 | otherwise -> Right ("reduced main " ++ ppShow te, ppShow e)
214 | otherwise = \case 214 | otherwise = case e of
215 Left (e, i) -> Right ("error message", unlines $ e: listAllInfos i) 215 Left e -> Right ("error message", unlines $ e: listAllInfos i)
216 Right _ -> Left (tab "!Failed" "failed to catch error", Failed) 216 Right _ -> Left (tab "!Failed" "failed to catch error", Failed)
217 217
218 tab msg 218 tab msg