summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2023-12-12 19:55:34 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2023-12-12 19:55:34 +0100
commit5b1b94aab78f210fd32f92f7d96857b448da73ca (patch)
tree74d8e1c5399c95122e43b640ccf51dee4a9098e5
parent224366e2c668784952ab613c7640d7017ce60990 (diff)
Repeat option on command line
Changelog: Add --repeat option to run the tests multiple times
-rw-r--r--src/Main.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/Main.hs b/src/Main.hs
index 20b3da2..fee776f 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -25,6 +25,7 @@ import Version
data CmdlineOptions = CmdlineOptions
{ optTest :: TestOptions
+ , optRepeat :: Int
, optShowVersion :: Bool
, optVerbose :: Bool
}
@@ -32,6 +33,7 @@ data CmdlineOptions = CmdlineOptions
defaultCmdlineOptions :: CmdlineOptions
defaultCmdlineOptions = CmdlineOptions
{ optTest = defaultTestOptions
+ , optRepeat = 1
, optShowVersion = False
, optVerbose = False
}
@@ -61,6 +63,9 @@ options =
, Option ['k'] ["keep"]
(NoArg $ to $ \opts -> opts { optKeep = True })
"keep test directory even if all tests succeed"
+ , Option ['r'] ["repeat"]
+ (ReqArg (\str opts -> opts { optRepeat = read str }) "COUNT")
+ "number of times to repeat the test(s)"
, Option ['V'] ["version"]
(NoArg $ \opts -> opts { optShowVersion = True })
"show version and exit"
@@ -118,5 +123,6 @@ main = do
Nothing -> fileTests
Just name -> filter ((==name) . testName) fileTests
- ok <- allM (runTest out $ optTest opts) $ concat tests
+ ok <- allM (runTest out $ optTest opts) $
+ concatMap (replicate (optRepeat opts)) $ concat tests
when (not ok) exitFailure