diff --git a/sydtest/src/Test/Syd/Runner.hs b/sydtest/src/Test/Syd/Runner.hs index 67912cb..3073a99 100644 --- a/sydtest/src/Test/Syd/Runner.hs +++ b/sydtest/src/Test/Syd/Runner.hs @@ -30,6 +30,14 @@ import Test.Syd.SpecDef import Text.Colour import Text.Printf +-- | Set the command line argument of the underlying action to empty. +-- +-- The action behaves as if no command line argument were provided. Especially, +-- it removes all the arguments initially provided to sydtest and provides a +-- reproducible environment. +setNullArgs :: IO a -> IO a +setNullArgs action = withArgs [] action + sydTestResult :: Settings -> TestDefM '[] () r -> IO (Timed ResultForest) sydTestResult settings spec = do let totalIterations = case settingIterations settings of @@ -44,7 +52,7 @@ sydTestOnce :: Settings -> TestDefM '[] () r -> IO (Timed ResultForest) sydTestOnce settings spec = do specForest <- execTestDefM settings spec tc <- deriveTerminalCapababilities settings - withArgs [] $ do + setNullArgs $ do setPseudorandomness (settingSeed settings) case settingThreads settings of Synchronous -> runSpecForestInterleavedWithOutputSynchronously settings specForest @@ -71,7 +79,7 @@ sydTestOnce settings spec = do sydTestIterations :: Maybe Word -> Settings -> TestDefM '[] () r -> IO (Timed ResultForest) sydTestIterations totalIterations settings spec = - withArgs [] $ do + setNullArgs $ do nbCapabilities <- fromIntegral <$> getNumCapabilities let runOnce settings_ = do