-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpull.hs
39 lines (34 loc) · 1.06 KB
/
pull.hs
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
#!/usr/bin/env cabal exec runhaskell
module Main where
import Control.Monad
import Control.Monad.Trans
import Control.Monad.Trans.Maybe
import System.Directory
import System.Exit
import System.FilePath
import System.Process
liftS :: IO ExitCode -> MaybeT IO ()
liftS cmd = MaybeT $ do
x <- cmd
case x of
ExitSuccess -> return $ Just ()
_ -> return Nothing
test_dir :: FilePath
test_dir = "literate-unitb-test"
main :: IO (Maybe ())
main = runMaybeT $ do
source_dir <- lift $ takeFileName `liftM` getCurrentDirectory
lift $ do
setCurrentDirectory ".."
ex <- doesDirectoryExist test_dir
if ex
then removeDirectoryRecursive test_dir
else return ()
createDirectory test_dir
setCurrentDirectory test_dir
liftS $ rawSystem "git" ["init"]
liftS $ rawSystem "git" ["remote","add","origin",".." </> source_dir]
liftS $ rawSystem "git" ["pull","origin","master"]
liftS $ rawSystem "ghc" ["test.hs","-threaded"]
liftS $ rawSystem "runghc" ["run_tests.hs"]
return ()