summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2011-05-23 15:37:13 +0100
committerWill Thompson <will.thompson@collabora.co.uk>2011-05-23 15:37:13 +0100
commitf40bf230953d754577437143a919012d160f91c8 (patch)
treed1d69f965664f34ea6e475486dbe5c38a3ec36ec
parent0c70ed844e4cc8698f49b6650648963a9a08b9d9 (diff)
Factor out actually invoking make n times
-rwxr-xr-xtt.hs23
1 files changed, 13 insertions, 10 deletions
diff --git a/tt.hs b/tt.hs
index 39b9350..b5228ab 100755
--- a/tt.hs
+++ b/tt.hs
@@ -84,6 +84,18 @@ usage = usageInfo header optionDefinitions
header = "Usage: tt [-v] [-V] [-d DIALECTS] [-r[N]] [tests...]"
{- Building and execution of a `make check-twisted` invocation -}
+invokeMake :: [String] -> IO ()
+invokeMake args = do
+ (_, _, _, h) <- createProcess $ proc "make" args
+ exitCode <- waitForProcess h
+ case exitCode of
+ ExitSuccess -> return ()
+ ExitFailure _ -> exitWith exitCode
+
+rep :: Repetitions -> IO () -> IO ()
+rep Forever = forever
+rep (Times n) = replicateM_ n
+
runTests :: FilePath -> String -> Bool -> [String] -> [Flag] -> Repetitions
-> IO ()
runTests testDir testVar inTree tests flags reps = do
@@ -98,16 +110,7 @@ runTests testDir testVar inTree tests flags reps = do
]
args = [ "check-twisted", "-s", "-C", testDir ] ++ t ++ flags
- let run = do
- (_, _, _, h) <- createProcess $ proc "make" args
- exitCode <- waitForProcess h
- case exitCode of
- ExitSuccess -> return ()
- ExitFailure _ -> exitWith exitCode
-
- case reps of
- Forever -> forever run
- Times n -> replicateM_ n run
+ rep reps $ invokeMake args
unprefix :: FilePath -> String -> String
unprefix testDir = fromMaybe <*> stripPrefix testDir