If there is an error, show the messages again at the end, so you don't have to scroll...
authorNeil Mitchell <ndmitchell@gmail.com>
Mon, 10 Nov 2014 11:05:56 +0000 (11:05 +0000)
committerNeil Mitchell <ndmitchell@gmail.com>
Mon, 10 Nov 2014 11:05:56 +0000 (11:05 +0000)
tests/Test.hs

index e3e0103..a7d82df 100755 (executable)
@@ -4,6 +4,7 @@ module Test(main) where
 import System.Environment
 import TestGen
 import Control.Monad
+import Data.Maybe
 import Test.QuickCheck
 
 
@@ -13,14 +14,16 @@ main = do
     let count = case args of i:_ -> read i; _ -> 10000
     putStrLn $ "Testing with " ++ show count ++ " repetitions"
     let total = length tests
-    bs <- forM (zip [1..] tests) $ \(i,(msg,prop)) -> do
+    bad <- fmap catMaybes $ forM (zip [1..] tests) $ \(i,(msg,prop)) -> do
         putStrLn $ "Test " ++ show i ++ " of " ++ show total ++ ": " ++ msg
         res <- quickCheckWithResult stdArgs{chatty=False, maxSuccess=count} prop
         case res of
-            Success{} -> return True
-            _ -> putStrLn "TEST FAILURE!" >> return False
-    let bad = length $ filter (== False) bs
-    if bad == 0 then
+            Success{} -> return Nothing
+            bad -> do print bad; putStrLn "TEST FAILURE!"; return $ Just (msg,bad)
+    if null bad then
         putStrLn $ "Success, " ++ show total ++ " tests passed"
-     else
-        fail $ "FAILURE, failed " ++ show bad ++ " of " ++ show total ++ " tests (look for FAILURE)"
+     else do
+        putStrLn $ show (length bad) ++ " FAILURES\n"
+        forM_ (zip [1..] bad) $ \(i,(a,b)) ->
+            putStrLn $ "FAILURE " ++ show i ++ ": " ++ a ++ "\n" ++ show b ++ "\n"
+        fail $ "FAILURE, failed " ++ show (length bad) ++ " of " ++ show total ++ " tests"