diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-01-25 12:22:01 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-01-25 12:22:01 +0100 |
commit | 75e73244ec78501ecaa6d7e70a6be8d32583b920 (patch) | |
tree | 49cac9301069e70a8727a2d2bd508964b04feb49 /test | |
parent | 5ecdf370bad4ea68f83d918688c69889f2d40bf7 (diff) |
new timed-out category; show run time of chrashed tests too
Diffstat (limited to 'test')
-rw-r--r-- | test/runTests.hs | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/test/runTests.hs b/test/runTests.hs index f28cb1c5..48cb9fae 100644 --- a/test/runTests.hs +++ b/test/runTests.hs | |||
@@ -39,10 +39,10 @@ import Text.Parsec.Pos | |||
39 | 39 | ||
40 | testDataPath = "./testdata" | 40 | testDataPath = "./testdata" |
41 | 41 | ||
42 | data Res = Passed | Accepted | New | Rejected | Failed | ErrorCatched | 42 | data Res = Passed | Accepted | New | TimedOut | Rejected | Failed | ErrorCatched |
43 | deriving (Eq, Ord, Show) | 43 | deriving (Eq, Ord, Show) |
44 | 44 | ||
45 | erroneous = (>= Rejected) | 45 | erroneous = (>= TimedOut) |
46 | 46 | ||
47 | instance NFData Res where | 47 | instance NFData Res where |
48 | rnf a = a `seq` () | 48 | rnf a = a `seq` () |
@@ -142,6 +142,7 @@ main = do | |||
142 | [ sh "crashed test" ErrorCatched | 142 | [ sh "crashed test" ErrorCatched |
143 | , sh "failed test" Failed | 143 | , sh "failed test" Failed |
144 | , sh "rejected result" Rejected | 144 | , sh "rejected result" Rejected |
145 | , sh "timed out test" TimedOut | ||
145 | , sh "new result" New | 146 | , sh "new result" New |
146 | , sh "accepted result" Accepted | 147 | , sh "accepted result" Accepted |
147 | , sh "wip passed test" Passed | 148 | , sh "wip passed test" Passed |
@@ -182,18 +183,14 @@ testFrame Config{..} dirs f tests | |||
182 | = local (const $ ioFetch dirs') | 183 | = local (const $ ioFetch dirs') |
183 | $ forM (zip [1..] (tests :: [TestCasePath])) $ \(i, tn) -> do | 184 | $ forM (zip [1..] (tests :: [TestCasePath])) $ \(i, tn) -> do |
184 | let n = testCaseVal tn | 185 | let n = testCaseVal tn |
185 | let er e = do | 186 | er e = return ("\n!Crashed\n" ++ tab e, (,) ErrorCatched <$> tn) |
186 | liftIO $ putStr $ n ++ "\n!Crashed\n" ++ tab e | 187 | (runtime, (msg, result)) <- timeOut cfgTimeout ("\n!Timed Out", (,) TimedOut <$> tn) $ catchErr er $ do |
187 | return $ (,) 0 . (,) ErrorCatched <$> tn | 188 | result <- liftIO . evaluate =<< (force <$> action n) |
188 | catchErr er $ do | 189 | liftIO $ case result of |
189 | (runtime, result) <- timeOut cfgTimeout (Left "Timed Out") (liftIO . evaluate =<< (force <$> action n)) | 190 | Left e -> return ("\n!Failed\n" ++ tab e, (,) Failed <$> tn) |
190 | fmap ((,) runtime <$>) $ liftIO $ case result of | 191 | Right (op, x) -> (,) "" <$> (if cfgReject then alwaysReject else compareResult) tn (pad 15 op) (head dirs' </> (n ++ ".out")) x |
191 | Left e -> do | 192 | liftIO $ putStrLn $ n ++" (" ++ showTime runtime ++ ")" ++ msg |
192 | putStr $ n ++" (" ++ showTime runtime ++ ")\n!Failed\n" ++ tab e | 193 | return $ (,) runtime <$> result |
193 | return $ (,) Failed <$> tn | ||
194 | Right (op, x) -> do | ||
195 | putStrLn $ n ++ " (" ++ showTime runtime ++ ")" | ||
196 | (if cfgReject then alwaysReject else compareResult) tn (pad 15 op) (head dirs' </> (n ++ ".out")) x | ||
197 | where | 194 | where |
198 | dirs_ = [takeDirectory f | f <- map testCaseVal tests, takeFileName f /= f] | 195 | dirs_ = [takeDirectory f | f <- map testCaseVal tests, takeFileName f /= f] |
199 | dirs' = dirs ++ dirs_ -- if null dirs_ then dirs else dirs_ | 196 | dirs' = dirs ++ dirs_ -- if null dirs_ then dirs else dirs_ |