From 5b1b94aab78f210fd32f92f7d96857b448da73ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Tue, 12 Dec 2023 19:55:34 +0100 Subject: Repeat option on command line Changelog: Add --repeat option to run the tests multiple times --- src/Main.hs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3