blob: 32ee399254340478a04fbb78c5700c13beaeabe8 (
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
|
module Main where
import Spec
import System.Exit
import System.Environment
import System.Process
import System.Directory
import Control.Exception
import Data.List
import Data.Maybe
import Data.Functor
clients :: [(String, String)]
clients = [
("rtorrent","rtorrent -p 51234-51234 testfile.torrent") ]
main :: IO ()
main = do
args <- getArgs
let cmd' = do
cl <- listToMaybe $ reverse
$ map (tail . dropWhile (/='='))
$ filter (isPrefixOf "--bittorrent-client=") args
cmd <- (++) "screen -dm -S bittorrent-testsuite " <$> lookup cl clients
return cmd
case cmd' of
Just cmd -> do _ <- system "screen -S bittorrent-testsuite -X quit"
dir <- getCurrentDirectory
_ <- createProcess (shell cmd) { cwd = Just (dir ++ "/res") }
return ()
Nothing -> return ()
let args' = (filter (not . isPrefixOf "--bittorrent-client=") args)
code <- catch (withArgs args' hspecMain >> return ExitSuccess) return
_ <- system "screen -S bittorrent-testsuite -X quit"
exitWith code >> return ()
|