diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-01-25 03:08:42 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-01-25 10:34:14 +0100 |
commit | 6a5dc25f766a894dfa0e97140936dda48f6f0e62 (patch) | |
tree | bf49c56f7d4950eb333b9ae75ce62a1a613e7e66 /test/runTests.hs | |
parent | f38ab4e25a5e4ea9a1a5bae610239e0741c426a9 (diff) |
apply hlint suggestions
Diffstat (limited to 'test/runTests.hs')
-rw-r--r-- | test/runTests.hs | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/test/runTests.hs b/test/runTests.hs index 4637ca65..78a49a47 100644 --- a/test/runTests.hs +++ b/test/runTests.hs | |||
@@ -1,4 +1,5 @@ | |||
1 | {-# LANGUAGE OverloadedStrings, PackageImports, LambdaCase #-} | 1 | {-# LANGUAGE OverloadedStrings #-} |
2 | {-# LANGUAGE LambdaCase #-} | ||
2 | {-# LANGUAGE FlexibleContexts #-} | 3 | {-# LANGUAGE FlexibleContexts #-} |
3 | {-# LANGUAGE RecordWildCards #-} | 4 | {-# LANGUAGE RecordWildCards #-} |
4 | {-# LANGUAGE DeriveFunctor #-} | 5 | {-# LANGUAGE DeriveFunctor #-} |
@@ -50,12 +51,12 @@ readFileStrict :: FilePath -> IO String | |||
50 | readFileStrict = fmap T.unpack . TIO.readFile | 51 | readFileStrict = fmap T.unpack . TIO.readFile |
51 | 52 | ||
52 | getDirectoryContentsRecursive path = do | 53 | getDirectoryContentsRecursive path = do |
53 | l <- map (path </>) . filter (\n -> notElem n [".",".."]) <$> getDirectoryContents path | 54 | l <- map (path </>) . filter (`notElem` [".",".."]) <$> getDirectoryContents path |
54 | -- ignore sub directories that name include .ignore | 55 | -- ignore sub directories that name include .ignore |
55 | dirs <- filter (not . isInfixOf ".ignore") <$> filterM doesDirectoryExist l | 56 | dirs <- filter (not . isInfixOf ".ignore") <$> filterM doesDirectoryExist l |
56 | files <- filterM doesFileExist l | 57 | files <- filterM doesFileExist l |
57 | innerContent <- mapM getDirectoryContentsRecursive dirs | 58 | innerContent <- mapM getDirectoryContentsRecursive dirs |
58 | return $ concat $ (filter ((".lc" ==) . takeExtension) files) : innerContent | 59 | return $ concat $ filter ((".lc" ==) . takeExtension) files : innerContent |
59 | 60 | ||
60 | data Config | 61 | data Config |
61 | = Config | 62 | = Config |
@@ -117,10 +118,10 @@ main = do | |||
117 | exitFailure | 118 | exitFailure |
118 | 119 | ||
119 | resultDiffs <- runMM' $ do | 120 | resultDiffs <- runMM' $ do |
120 | liftIO $ putStrLn $ "------------------------------------ Checking valid pipelines" | 121 | liftIO $ putStrLn "------------------------------------ Checking valid pipelines" |
121 | acceptDiffs <- acceptTests cfg $ testToAccept ++ testToAcceptWIP | 122 | acceptDiffs <- acceptTests cfg $ testToAccept ++ testToAcceptWIP |
122 | 123 | ||
123 | liftIO $ putStrLn $ "------------------------------------ Catching errors (must get an error)" | 124 | liftIO $ putStrLn "------------------------------------ Catching errors (must get an error)" |
124 | rejectDiffs <- rejectTests cfg $ testToReject ++ testToRejectWIP | 125 | rejectDiffs <- rejectTests cfg $ testToReject ++ testToRejectWIP |
125 | 126 | ||
126 | return $ acceptDiffs ++ rejectDiffs | 127 | return $ acceptDiffs ++ rejectDiffs |
@@ -189,7 +190,7 @@ timeOut :: Int -> a -> MM a -> MM (NominalDiffTime, a) | |||
189 | timeOut n d = mapMMT $ \m -> | 190 | timeOut n d = mapMMT $ \m -> |
190 | control (\runInIO -> | 191 | control (\runInIO -> |
191 | race' (runInIO $ timeDiff m) | 192 | race' (runInIO $ timeDiff m) |
192 | (runInIO $ timeDiff ((liftIO $ threadDelay (n * 1000000)) >> return d)) | 193 | (runInIO $ timeDiff $ liftIO (threadDelay $ n * 1000000) >> return d) |
193 | ) | 194 | ) |
194 | where | 195 | where |
195 | race' a b = either id id <$> race a b | 196 | race' a b = either id id <$> race a b |
@@ -202,7 +203,7 @@ testFrame_ timeout compareResult path action tests = fmap concat $ forM (zip [1. | |||
202 | let n = testCaseVal tn | 203 | let n = testCaseVal tn |
203 | let er e = do | 204 | let er e = do |
204 | liftIO $ putStr $ n ++ "\n!Crashed\n" ++ tab e | 205 | liftIO $ putStr $ n ++ "\n!Crashed\n" ++ tab e |
205 | return $ [(,) ErrorCatched <$> tn] | 206 | return [(,) ErrorCatched <$> tn] |
206 | catchErr er $ do | 207 | catchErr er $ do |
207 | (runtime, result) <- timeOut timeout (Left "Timed Out") (liftIO . evaluate =<< (force <$> action n)) | 208 | (runtime, result) <- timeOut timeout (Left "Timed Out") (liftIO . evaluate =<< (force <$> action n)) |
208 | liftIO $ case result of | 209 | liftIO $ case result of |
@@ -220,6 +221,13 @@ testFrame_ timeout compareResult path action tests = fmap concat $ forM (zip [1. | |||
220 | | otherwise = printf "%.0fus" (t/1e-6) | 221 | | otherwise = printf "%.0fus" (t/1e-6) |
221 | in res | 222 | in res |
222 | 223 | ||
224 | printOldNew msg old new = do | ||
225 | putStrLn $ msg ++ " has changed." | ||
226 | putStrLn "------------------------------------------- Old" | ||
227 | putStrLn old | ||
228 | putStrLn "------------------------------------------- New" | ||
229 | putStrLn new | ||
230 | putStrLn "-------------------------------------------" | ||
223 | 231 | ||
224 | -- Reject unrigestered or chaned results automatically | 232 | -- Reject unrigestered or chaned results automatically |
225 | alwaysReject tn msg ef e = do | 233 | alwaysReject tn msg ef e = do |
@@ -231,12 +239,7 @@ alwaysReject tn msg ef e = do | |||
231 | case map fst $ filter snd $ zip [0..] $ zipWith (/=) e e' of | 239 | case map fst $ filter snd $ zip [0..] $ zipWith (/=) e e' of |
232 | [] -> return [(,) Passed <$> tn] | 240 | [] -> return [(,) Passed <$> tn] |
233 | rs -> do | 241 | rs -> do |
234 | putStrLn $ msg ++ " has changed." | 242 | printOldNew msg (showRanges ef rs e') (showRanges ef rs e) |
235 | putStrLn "------------------------------------------- Old" | ||
236 | putStrLn $ showRanges ef rs e' | ||
237 | putStrLn "------------------------------------------- New" | ||
238 | putStrLn $ showRanges ef rs e | ||
239 | putStrLn "-------------------------------------------" | ||
240 | return [(,) Rejected <$> tn, (,) Failed <$> tn] | 243 | return [(,) Rejected <$> tn, (,) Failed <$> tn] |
241 | 244 | ||
242 | compareResult tn msg ef e = do | 245 | compareResult tn msg ef e = do |
@@ -248,12 +251,7 @@ compareResult tn msg ef e = do | |||
248 | case map fst $ filter snd $ zip [0..] $ zipWith (/=) e e' ++ replicate (abs $ length e - length e') True of | 251 | case map fst $ filter snd $ zip [0..] $ zipWith (/=) e e' ++ replicate (abs $ length e - length e') True of |
249 | [] -> return [(,) Passed <$> tn] | 252 | [] -> return [(,) Passed <$> tn] |
250 | rs -> do | 253 | rs -> do |
251 | putStrLn $ msg ++ " has changed." | 254 | printOldNew msg (showRanges ef rs e') (showRanges ef rs e) |
252 | putStrLn "------------------------------------------- Old" | ||
253 | putStrLn $ showRanges ef rs e' | ||
254 | putStrLn "------------------------------------------- New" | ||
255 | putStrLn $ showRanges ef rs e | ||
256 | putStrLn "-------------------------------------------" | ||
257 | putStr $ "Accept new " ++ msg ++ " (y/n)? " | 255 | putStr $ "Accept new " ++ msg ++ " (y/n)? " |
258 | c <- length e' `seq` getChar | 256 | c <- length e' `seq` getChar |
259 | if c `elem` ("yY\n" :: String) | 257 | if c `elem` ("yY\n" :: String) |