blob: d84f92d607110f7674c64374e0849f843615af04 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DoAndIfThenElse #-}
import System.Environment
--import System.Posix.Env.ByteString (getEnv)
import System.Posix.Files
import Test.Hspec
import System.Process
import Control.Exception
import System.Directory
import System.FilePath
import System.Exit
import System.IO
--import System.Posix.ByteString.FilePath
import Control.Applicative
import Control.Monad
data TestKikiSettings = TKS
{ chroot :: FilePath
}
deriving (Show,Eq)
kiki = "./dist/build/kiki/kiki"
main = do
args <- getArgs
cwd <- getCurrentDirectory
let chomp x = takeWhile (/='\n') x
date <- maybe (return "")
(\x -> chomp <$> readProcess x ["+%Y-%m-%d-%H%M"] "") =<< findExecutable "date"
let tdir = cwd </> "TESTS" </> date
{- -- Remove old TESTS, clean up directory
- -- XXX: get this to work right with HSpec
-
- when (args == ["clean"]) $ do
- removeDirectoryRecursive (cwd </> "TESTS")
-}
existsAlready <- or <$> (sequence $ map ($ tdir) [doesDirectoryExist,doesFileExist])
if existsAlready then do
hPutStrLn stderr ("Path " ++ show tdir ++ " already exists, remove or change working folder to run clean tests.")
exitFailure
else do
let chrootdir = cwd </> tdir </> "chroot"
createDirectoryIfMissing True chrootdir
let config = TKS { chroot = chrootdir }
print config
putStrLn "==="
doTests config
doTests :: TestKikiSettings -> IO ()
doTests tkConfig = hspec $ do
describe "TODO: error" $
it "throws an exception" $
evaluate (error "TODO:testsuite") `shouldThrow` anyException
|