From c52b613ac4466f85d5a7bd5cfb4f5bbd9b9285d6 Mon Sep 17 00:00:00 2001 From: Filip Gralinski Date: Thu, 14 Feb 2019 22:57:29 +0100 Subject: [PATCH] Handle JSON Lines files --- Handler/CreateChallenge.hs | 4 ++-- Handler/ShowChallenge.hs | 5 +++-- gonito.cabal | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Handler/CreateChallenge.hs b/Handler/CreateChallenge.hs index 52aac75..4d4098a 100644 --- a/Handler/CreateChallenge.hs +++ b/Handler/CreateChallenge.hs @@ -141,8 +141,8 @@ expectedFileName = "expected.tsv" doesExpectedExist :: FilePath -> IO Bool doesExpectedExist fp = do - ef <- findFilePossiblyCompressed (fp expectedFileName) - return $ isJust ef + efs <- mapM (\ext -> findFilePossiblyCompressed (fp expectedFileName -<.> ext)) extensionsHandled + return $ not $ null $ catMaybes efs checkTestDir :: Channel -> (Key Challenge) -> Challenge -> SHA1 -> FilePath -> Handler () checkTestDir chan challengeId challenge commit testDir = do diff --git a/Handler/ShowChallenge.hs b/Handler/ShowChallenge.hs index a6241b3..a4e9adf 100644 --- a/Handler/ShowChallenge.hs +++ b/Handler/ShowChallenge.hs @@ -37,7 +37,7 @@ import Options.Applicative import System.IO (readFile) -import System.FilePath (takeFileName, dropExtensions) +import System.FilePath (takeFileName, dropExtensions, (-<.>)) import Data.Text (pack, unpack) @@ -411,7 +411,8 @@ getOutFilePath repoDir test = repoDir (T.unpack $ testName test) outFile findOutFile :: FilePath -> Test -> IO (Maybe FilePath) findOutFile repoDir test = do let baseOut = getOutFilePath repoDir test - findFilePossiblyCompressed baseOut + ofs <- mapM (\ext -> findFilePossiblyCompressed (baseOut -<.> ext)) extensionsHandled + return $ listToMaybe $ catMaybes ofs doesOutExist :: FilePath -> Entity Test -> IO Bool doesOutExist repoDir (Entity _ test) = do diff --git a/gonito.cabal b/gonito.cabal index 02f0ffe..58081eb 100644 --- a/gonito.cabal +++ b/gonito.cabal @@ -126,7 +126,7 @@ library , filemanip , cryptohash , markdown - , geval >= 1.13.0.0 && < 1.17 + , geval >= 1.16.1.0 && < 1.17 , filepath , yesod-table , regex-tdfa