summaryrefslogtreecommitdiff
path: root/test/runTests.hs
diff options
context:
space:
mode:
authorPéter Diviánszky <divipp@gmail.com>2016-02-04 03:22:18 +0100
committerPéter Diviánszky <divipp@gmail.com>2016-02-04 03:22:18 +0100
commitdb463d1f9a975fd75082c760bec47fc9296a4171 (patch)
treec0a7dd4feb7746e72dcb646da73e126135e2573c /test/runTests.hs
parent8fc9ab3fe5e1f358c85959dfc1d87d100e7ef2d2 (diff)
begin to support qualified module names
Diffstat (limited to 'test/runTests.hs')
-rw-r--r--test/runTests.hs46
1 files changed, 28 insertions, 18 deletions
diff --git a/test/runTests.hs b/test/runTests.hs
index c9375d5d..3b5a18e7 100644
--- a/test/runTests.hs
+++ b/test/runTests.hs
@@ -94,6 +94,15 @@ arguments =
94data Res = Passed | Accepted | New | TimedOut | Rejected | Failed | ErrorCatched 94data Res = Passed | Accepted | New | TimedOut | Rejected | Failed | ErrorCatched
95 deriving (Eq, Ord, Show) 95 deriving (Eq, Ord, Show)
96 96
97showRes = \case
98 ErrorCatched -> "crashed test"
99 Failed -> "failed test"
100 Rejected -> "rejected result"
101 TimedOut -> "timed out test"
102 New -> "new result"
103 Accepted -> "accepted result"
104 Passed -> "passed test"
105
97instance NFData Res where 106instance NFData Res where
98 rnf a = a `seq` () 107 rnf a = a `seq` ()
99 108
@@ -128,27 +137,28 @@ main = do
128 putStrLn $ "------------------------------------ Running " ++ show (length testSet) ++ " tests" 137 putStrLn $ "------------------------------------ Running " ++ show (length testSet) ++ " tests"
129 138
130 (Right resultDiffs, _) 139 (Right resultDiffs, _)
131 <- runMM (ioFetch $ nub $ [".",testDataPath] ++ [takeDirectory f | f <- testSet, takeFileName f /= f]) 140 <- runMM (ioFetch [".", testDataPath])
132 $ forM (zip [1..] testSet) $ doTest cfg 141 $ forM (zip [1..] testSet) $ doTest cfg
133 142
134 let sh b ty = [(if erroneous ty then "!" else "") ++ show noOfResult ++ " " ++ pad 10 (b ++ plural ++ ": ") ++ "\n" ++ unlines ss 143 let sh :: (FilePath -> Res -> Bool) -> String -> [String]
135 | not $ null ss] 144 sh p b = [ (if any (\(ty, s) -> erroneous ty && not (isWip s)) ss then "!" else "")
145 ++ show noOfResult ++ " "
146 ++ pad 10 (b ++ plural ++ ": ") ++ "\n"
147 ++ unlines (map snd ss)
148 | not $ null ss ]
136 where 149 where
137 ss = [s | ((_, ty'), s) <- zip resultDiffs testSet, ty' == ty, ty /= Passed || isWip s] 150 ss = [(ty, s) | ((_, ty), s) <- zip resultDiffs testSet, p s ty]
138 noOfResult = length ss 151 noOfResult = length ss
139 plural = ['s' | noOfResult > 1] 152 plural = ['s' | noOfResult > 1]
140 153
141 putStrLn $ unlines $ concat 154 putStrLn "------------------------------------ Summary"
142 [ ["------------------------------------ Summary"] 155 putStrLn $ unlines $ reverse $
143 , sh "crashed test" ErrorCatched 156 concat [ sh (\s ty -> ty == x && p s) (w ++ showRes x)
144 , sh "failed test" Failed 157 | (w, p) <- [("", not . isWip), ("wip ", isWip)]
145 , sh "rejected result" Rejected 158 , x <- [ErrorCatched, Failed, Rejected, TimedOut, New, Accepted]
146 , sh "timed out test" TimedOut 159 ]
147 , sh "new result" New 160 ++ sh (\s ty -> ty == Passed && isWip s) "wip passed test"
148 , sh "accepted result" Accepted 161 ++ ["Overall time: " ++ showTime (sum $ map fst resultDiffs)]
149 , sh "wip passed test" Passed
150 , ["Overall time: " ++ showTime (sum $ map fst resultDiffs)]
151 ]
152 162
153 when (or [erroneous r | ((_, r), f) <- zip resultDiffs testSet, not $ isWip f]) exitFailure 163 when (or [erroneous r | ((_, r), f) <- zip resultDiffs testSet, not $ isWip f]) exitFailure
154 putStrLn "All OK" 164 putStrLn "All OK"
@@ -156,10 +166,10 @@ main = do
156 putStrLn "Only work in progress test cases are failing." 166 putStrLn "Only work in progress test cases are failing."
157 167
158doTest Config{..} (i, fn) = do 168doTest Config{..} (i, fn) = do
159 liftIO $ putStr $ n ++ " " 169 liftIO $ putStr $ fn ++ " "
160 (runtime, res) <- mapMMT (timeOut cfgTimeout $ Left ("!Timed Out", TimedOut)) 170 (runtime, res) <- mapMMT (timeOut cfgTimeout $ Left ("!Timed Out", TimedOut))
161 $ catchErr (\e -> return $ Left (tab "!Crashed" e, ErrorCatched)) 171 $ catchErr (\e -> return $ Left (tab "!Crashed" e, ErrorCatched))
162 $ liftIO . evaluate =<< (force <$> action n) 172 $ liftIO . evaluate =<< (force <$> action)
163 liftIO $ putStr $ "(" ++ showTime runtime ++ ")" ++ " " 173 liftIO $ putStr $ "(" ++ showTime runtime ++ ")" ++ " "
164 (msg, result) <- case res of 174 (msg, result) <- case res of
165 Left x -> return x 175 Left x -> return x
@@ -169,7 +179,7 @@ doTest Config{..} (i, fn) = do
169 where 179 where
170 n = dropExtension fn 180 n = dropExtension fn
171 181
172 action n = f <$> (Right <$> getDef n "main" Nothing) `catchMM` (return . Left . show) 182 action = f <$> (Right <$> getDef n "main" Nothing) `catchMM` (return . Left . show)
173 183
174 f | not $ isReject fn = \case 184 f | not $ isReject fn = \case
175 Left e -> Left (tab "!Failed" e, Failed) 185 Left e -> Left (tab "!Failed" e, Failed)