blob: 6628333962669d5ee10f6f366fb910d746b80f5a (
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
|
module Main where
import Spec
import System.Exit
import System.Environment
import System.Process
import Control.Exception
import Data.List
import Data.Maybe
import Data.Functor
clients :: [(String, String)]
clients = [
("rtorrent","rtorrent -p 51234-51234 res/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"
createProcess (shell cmd) >> 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 ()
|