diff options
author | Péter Diviánszky <divipp@gmail.com> | 2016-02-17 11:21:35 +0100 |
---|---|---|
committer | Péter Diviánszky <divipp@gmail.com> | 2016-02-17 11:21:35 +0100 |
commit | ed7cff18118bddc2b57fe1738e7edb2fb0064305 (patch) | |
tree | ac38ae6e0e66103429a779c86ce36fc30ea465b3 /test/runTests.hs | |
parent | 02d18fe787cbe69d422ad9f76a5324f6ba86f4da (diff) |
better path handling
Diffstat (limited to 'test/runTests.hs')
-rw-r--r-- | test/runTests.hs | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/test/runTests.hs b/test/runTests.hs index 7be9cb4b..c36e6c59 100644 --- a/test/runTests.hs +++ b/test/runTests.hs | |||
@@ -5,11 +5,13 @@ | |||
5 | {-# LANGUAGE RecordWildCards #-} | 5 | {-# LANGUAGE RecordWildCards #-} |
6 | module Main where | 6 | module Main where |
7 | 7 | ||
8 | import Data.Char | ||
8 | import Data.List | 9 | import Data.List |
9 | import Data.Either | 10 | import Data.Either |
10 | import Data.Time.Clock | 11 | import Data.Time.Clock |
11 | import Data.Algorithm.Patience | 12 | import Data.Algorithm.Patience |
12 | import Control.Applicative | 13 | import Control.Applicative |
14 | import Control.Arrow | ||
13 | import Control.Concurrent | 15 | import Control.Concurrent |
14 | import Control.Concurrent.Async | 16 | import Control.Concurrent.Async |
15 | import Control.Monad | 17 | import Control.Monad |
@@ -43,9 +45,11 @@ getDirectoryContentsRecursive path = do | |||
43 | <*> (fmap concat . mapM getDirectoryContentsRecursive . filter ((".ignore" `notElem`) . takeExtensions') =<< filterM doesDirectoryExist l) | 45 | <*> (fmap concat . mapM getDirectoryContentsRecursive . filter ((".ignore" `notElem`) . takeExtensions') =<< filterM doesDirectoryExist l) |
44 | 46 | ||
45 | takeExtensions' :: FilePath -> [String] | 47 | takeExtensions' :: FilePath -> [String] |
46 | takeExtensions' fn = case splitExtension fn of | 48 | takeExtensions' = snd . splitExtensions' |
47 | (_, "") -> [] | 49 | |
48 | (fn', ext) -> ext: takeExtensions' fn' | 50 | splitExtensions' fn = case splitExtension fn of |
51 | (a, "") -> (a, []) | ||
52 | (fn', ext) -> second (ext:) $ splitExtensions' fn' | ||
49 | 53 | ||
50 | getYNChar = do | 54 | getYNChar = do |
51 | c <- getChar | 55 | c <- getChar |
@@ -170,8 +174,13 @@ main = do | |||
170 | when (or [erroneous r | ((_, r), f) <- zip resultDiffs testSet, isWip f]) $ | 174 | when (or [erroneous r | ((_, r), f) <- zip resultDiffs testSet, isWip f]) $ |
171 | putStrLn "Only work in progress test cases are failing." | 175 | putStrLn "Only work in progress test cases are failing." |
172 | 176 | ||
177 | splitMPath fn = (joinPath $ reverse as, foldr1 (</>) $ reverse bs ++ [y], intercalate "." $ reverse bs ++ [y]) | ||
178 | where | ||
179 | (bs, as) = span (\x -> not (null x) && isUpper (head x)) $ reverse xs | ||
180 | (xs, y) = map takeDirectory . splitPath *** id $ splitFileName $ dropExtension fn | ||
181 | |||
173 | doTest Config{..} (i, fn) = do | 182 | doTest Config{..} (i, fn) = do |
174 | liftIO $ putStr $ fn ++ " " | 183 | liftIO $ putStr $ pa ++ " " ++ mn ++ " " ++ concat exts ++ " " |
175 | (runtime, res) <- mapMMT (timeOut cfgTimeout $ Left ("!Timed Out", TimedOut)) | 184 | (runtime, res) <- mapMMT (timeOut cfgTimeout $ Left ("!Timed Out", TimedOut)) |
176 | $ catchErr (\e -> return $ Left (tab "!Crashed" e, ErrorCatched)) | 185 | $ catchErr (\e -> return $ Left (tab "!Crashed" e, ErrorCatched)) |
177 | $ liftIO . evaluate =<< (force <$> action) | 186 | $ liftIO . evaluate =<< (force <$> action) |
@@ -182,14 +191,14 @@ doTest Config{..} (i, fn) = do | |||
182 | liftIO $ putStrLn msg | 191 | liftIO $ putStrLn msg |
183 | return (runtime, result) | 192 | return (runtime, result) |
184 | where | 193 | where |
185 | n = dropExtension fn | 194 | (splitMPath -> (pa, mn', mn), exts) = splitExtensions' $ dropExtension fn |
186 | 195 | ||
187 | getMain n = do | 196 | getMain = do |
188 | r@(fname, x, _) <- getDef n "main" Nothing | 197 | r@(fname, x, _) <- local (const $ ioFetch [pa]) $ getDef (mn' ++ concat exts ++ ".lc") "main" Nothing |
189 | when (isRight x) $ removeFromCache fname | 198 | when (isRight x) $ removeFromCache fname |
190 | return r | 199 | return r |
191 | 200 | ||
192 | action = f <$> (Right <$> getMain n) `catchMM` (\e is -> return $ Left (e, is)) | 201 | action = f <$> (Right <$> getMain) `catchMM` (\e is -> return $ Left (e, is)) |
193 | 202 | ||
194 | f | not $ isReject fn = \case | 203 | f | not $ isReject fn = \case |
195 | Left (e, i) -> Left (unlines $ tab "!Failed" e: listTraceInfos i, Failed) | 204 | Left (e, i) -> Left (unlines $ tab "!Failed" e: listTraceInfos i, Failed) |