fix handling compressed expected files

This commit is contained in:
Filip Gralinski 2018-06-09 15:35:31 +02:00
parent d7c656217f
commit f7a85e80a0
4 changed files with 15 additions and 9 deletions

View File

@ -127,10 +127,13 @@ updateTests challengeId chan = do
msg chan (T.pack $ show testDirs)
return ()
expectedFileName :: FilePath
expectedFileName = "expected.tsv"
doesExpectedExist :: FilePath -> IO Bool
doesExpectedExist fp = doesFileExist (fp </> expectedFileName)
doesExpectedExist fp = do
ef <- findFilePossiblyCompressed (fp </> expectedFileName)
return $ isJust ef
checkTestDir :: Channel -> (Key Challenge) -> Challenge -> SHA1 -> FilePath -> Handler ()
checkTestDir chan challengeId challenge commit testDir = do

View File

@ -24,7 +24,7 @@ import qualified Data.List as DL
import System.Random
import System.Directory (renameDirectory)
import System.Directory (doesFileExist, renameDirectory)
import PersistSHA1
@ -331,3 +331,11 @@ formatTruncatedScore _ Nothing = formatFullScore Nothing
formatTruncatedScore (Just precision) (Just evaluation) = case evaluationScore evaluation of
Just score -> T.pack $ printf "%0.*f" precision score
Nothing -> formatFullScore Nothing
findFilePossiblyCompressed :: FilePath -> IO (Maybe FilePath)
findFilePossiblyCompressed baseFilePath = do
let possibleFiles = [baseFilePath] ++ (map (baseFilePath <.>) ["gz", "bz2", "xz"])
foundFiles <- filterM doesFileExist possibleFiles
return $ case foundFiles of
[] -> Nothing
(h:_) -> Just h

View File

@ -9,7 +9,6 @@ import Data.Monoid
import qualified Data.Text.Lazy as TL
import Text.Markdown
import System.Directory (doesFileExist)
import qualified Data.Text as T
import qualified Yesod.Table as Table
@ -289,11 +288,7 @@ getOutFilePath repoDir test = repoDir </> (T.unpack $ testName test) </> outFile
findOutFile repoDir test = do
let baseOut = getOutFilePath repoDir test
let possibleOuts = [baseOut] ++ (map (baseOut <.>) ["gz", "bz2", "xz"])
foundFiles <- filterM doesFileExist possibleOuts
return $ case foundFiles of
[] -> Nothing
(h:_) -> Just h
findFilePossiblyCompressed baseOut
doesOutExist repoDir (Entity _ test) = do
result <- findOutFile repoDir test

View File

@ -122,7 +122,7 @@ library
, filemanip
, cryptohash
, markdown
, geval >= 0.5.0.0
, geval >= 1.0.0.0
, filepath
, yesod-table
, regex-tdfa