create a challenge, cntd.
This commit is contained in:
parent
f6abc0f485
commit
cf5e473eee
@ -5,6 +5,7 @@ module GEval.Core
|
|||||||
MetricValue,
|
MetricValue,
|
||||||
GEvalSpecification(..),
|
GEvalSpecification(..),
|
||||||
GEvalOptions(..),
|
GEvalOptions(..),
|
||||||
|
GEvalException(..),
|
||||||
defaultGEvalSpecification,
|
defaultGEvalSpecification,
|
||||||
defaultOutDirectory,
|
defaultOutDirectory,
|
||||||
defaultTestName,
|
defaultTestName,
|
||||||
@ -67,6 +68,7 @@ data GEvalException = NoExpectedFile FilePath
|
|||||||
| NoOutDirectory FilePath
|
| NoOutDirectory FilePath
|
||||||
| NoExpectedTestDirectory FilePath
|
| NoExpectedTestDirectory FilePath
|
||||||
| NoOutTestDirectory FilePath
|
| NoOutTestDirectory FilePath
|
||||||
|
| FileAlreadyThere FilePath
|
||||||
|
|
||||||
instance Exception GEvalException
|
instance Exception GEvalException
|
||||||
|
|
||||||
@ -77,7 +79,7 @@ instance Show GEvalException where
|
|||||||
show (NoOutDirectory filePath) = somethingWrongWithFilesMessage "No directory with the test results" filePath
|
show (NoOutDirectory filePath) = somethingWrongWithFilesMessage "No directory with the test results" filePath
|
||||||
show (NoExpectedTestDirectory filePath) = somethingWrongWithFilesMessage "No test subdirectory with the expected results" filePath
|
show (NoExpectedTestDirectory filePath) = somethingWrongWithFilesMessage "No test subdirectory with the expected results" filePath
|
||||||
show (NoOutTestDirectory filePath) = somethingWrongWithFilesMessage "No test subdirectory with the results obtained" filePath
|
show (NoOutTestDirectory filePath) = somethingWrongWithFilesMessage "No test subdirectory with the results obtained" filePath
|
||||||
|
show (FileAlreadyThere filePath) = somethingWrongWithFilesMessage "File already there" filePath
|
||||||
|
|
||||||
somethingWrongWithFilesMessage :: String -> FilePath -> String
|
somethingWrongWithFilesMessage :: String -> FilePath -> String
|
||||||
somethingWrongWithFilesMessage msg filePath = Prelude.concat
|
somethingWrongWithFilesMessage msg filePath = Prelude.concat
|
||||||
|
@ -5,6 +5,17 @@ module GEval.CreateChallenge
|
|||||||
where
|
where
|
||||||
|
|
||||||
import GEval.Core
|
import GEval.Core
|
||||||
|
import qualified System.Directory as D
|
||||||
|
import Control.Conditional (whenM)
|
||||||
|
|
||||||
|
import System.IO
|
||||||
|
import Control.Exception
|
||||||
|
import Control.Monad.Trans.Resource
|
||||||
|
|
||||||
createChallenge :: FilePath -> GEvalSpecification -> IO ()
|
createChallenge :: FilePath -> GEvalSpecification -> IO ()
|
||||||
createChallenge expectedDirectory spec = putStrLn "creating challange..."
|
createChallenge expectedDirectory spec = putStrLn "creating challange..."
|
||||||
|
|
||||||
|
createFile :: FilePath -> String -> IO ()
|
||||||
|
createFile filePath contents = do
|
||||||
|
whenM (D.doesFileExist filePath) $ throwM $ FileAlreadyThere filePath
|
||||||
|
writeFile filePath contents
|
||||||
|
Loading…
Reference in New Issue
Block a user