fix handling compressed expected files
This commit is contained in:
parent
d7c656217f
commit
f7a85e80a0
@ -127,10 +127,13 @@ updateTests challengeId chan = do
|
|||||||
msg chan (T.pack $ show testDirs)
|
msg chan (T.pack $ show testDirs)
|
||||||
return ()
|
return ()
|
||||||
|
|
||||||
|
expectedFileName :: FilePath
|
||||||
expectedFileName = "expected.tsv"
|
expectedFileName = "expected.tsv"
|
||||||
|
|
||||||
doesExpectedExist :: FilePath -> IO Bool
|
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 :: Channel -> (Key Challenge) -> Challenge -> SHA1 -> FilePath -> Handler ()
|
||||||
checkTestDir chan challengeId challenge commit testDir = do
|
checkTestDir chan challengeId challenge commit testDir = do
|
||||||
|
@ -24,7 +24,7 @@ import qualified Data.List as DL
|
|||||||
|
|
||||||
import System.Random
|
import System.Random
|
||||||
|
|
||||||
import System.Directory (renameDirectory)
|
import System.Directory (doesFileExist, renameDirectory)
|
||||||
|
|
||||||
import PersistSHA1
|
import PersistSHA1
|
||||||
|
|
||||||
@ -331,3 +331,11 @@ formatTruncatedScore _ Nothing = formatFullScore Nothing
|
|||||||
formatTruncatedScore (Just precision) (Just evaluation) = case evaluationScore evaluation of
|
formatTruncatedScore (Just precision) (Just evaluation) = case evaluationScore evaluation of
|
||||||
Just score -> T.pack $ printf "%0.*f" precision score
|
Just score -> T.pack $ printf "%0.*f" precision score
|
||||||
Nothing -> formatFullScore Nothing
|
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
|
||||||
|
@ -9,7 +9,6 @@ import Data.Monoid
|
|||||||
import qualified Data.Text.Lazy as TL
|
import qualified Data.Text.Lazy as TL
|
||||||
import Text.Markdown
|
import Text.Markdown
|
||||||
|
|
||||||
import System.Directory (doesFileExist)
|
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
|
|
||||||
import qualified Yesod.Table as Table
|
import qualified Yesod.Table as Table
|
||||||
@ -289,11 +288,7 @@ getOutFilePath repoDir test = repoDir </> (T.unpack $ testName test) </> outFile
|
|||||||
|
|
||||||
findOutFile repoDir test = do
|
findOutFile repoDir test = do
|
||||||
let baseOut = getOutFilePath repoDir test
|
let baseOut = getOutFilePath repoDir test
|
||||||
let possibleOuts = [baseOut] ++ (map (baseOut <.>) ["gz", "bz2", "xz"])
|
findFilePossiblyCompressed baseOut
|
||||||
foundFiles <- filterM doesFileExist possibleOuts
|
|
||||||
return $ case foundFiles of
|
|
||||||
[] -> Nothing
|
|
||||||
(h:_) -> Just h
|
|
||||||
|
|
||||||
doesOutExist repoDir (Entity _ test) = do
|
doesOutExist repoDir (Entity _ test) = do
|
||||||
result <- findOutFile repoDir test
|
result <- findOutFile repoDir test
|
||||||
|
@ -122,7 +122,7 @@ library
|
|||||||
, filemanip
|
, filemanip
|
||||||
, cryptohash
|
, cryptohash
|
||||||
, markdown
|
, markdown
|
||||||
, geval >= 0.5.0.0
|
, geval >= 1.0.0.0
|
||||||
, filepath
|
, filepath
|
||||||
, yesod-table
|
, yesod-table
|
||||||
, regex-tdfa
|
, regex-tdfa
|
||||||
|
Loading…
Reference in New Issue
Block a user