diff --git a/lib/core/test/unit/Network/Wai/Middleware/LoggingSpec.hs b/lib/core/test/unit/Network/Wai/Middleware/LoggingSpec.hs index 3969456d72e..01fe819065b 100644 --- a/lib/core/test/unit/Network/Wai/Middleware/LoggingSpec.hs +++ b/lib/core/test/unit/Network/Wai/Middleware/LoggingSpec.hs @@ -97,6 +97,8 @@ import Test.QuickCheck ( Arbitrary (..), choose, property ) import Test.QuickCheck.Monadic ( monadicIO ) +import Test.Utils.Windows + ( pendingOnWindows, whenWindows ) import qualified Data.Aeson as Aeson import qualified Data.Map.Strict as Map @@ -195,6 +197,7 @@ spec = describe "Logging Middleware" entries <- readTVarIO (logs ctx) let index = Map.fromList $ catMaybes [ (loName l,) <$> captureTime l | l <- entries ] + pendingOnWindows "Disabled on windows due to race with log flushing" Map.size (Map.filter (> (200*ms)) index) `shouldBe` 1 where setup :: IO Context @@ -267,6 +270,8 @@ postIlled ctx path body = do expectLogs :: Context -> [(Severity, String)] -> IO () expectLogs ctx expectations = do + whenWindows $ threadDelay 1000000 -- let iohk-monitoring flush the logs + entries <- reverse <$> readTVarIO (logs ctx) when (length entries /= length expectations) $ diff --git a/lib/test-utils/src/Test/Utils/Windows.hs b/lib/test-utils/src/Test/Utils/Windows.hs index bc5d85997dc..f3eaf8215ce 100644 --- a/lib/test-utils/src/Test/Utils/Windows.hs +++ b/lib/test-utils/src/Test/Utils/Windows.hs @@ -8,6 +8,8 @@ module Test.Utils.Windows ( skipOnWindows + , pendingOnWindows + , whenWindows ) where import Prelude @@ -19,9 +21,15 @@ import Control.Monad import System.Info ( os ) import Test.Hspec.Core.Spec - ( ResultStatus (..) ) + ( ResultStatus (..), pendingWith ) import Test.Hspec.Expectations ( Expectation, HasCallStack ) skipOnWindows :: HasCallStack => String -> Expectation -skipOnWindows _reason = when (os == "mingw32") $ throwIO Success +skipOnWindows _reason = whenWindows $ throwIO Success + +pendingOnWindows :: HasCallStack => String -> Expectation +pendingOnWindows reason = whenWindows $ pendingWith reason + +whenWindows :: IO () -> IO () +whenWindows = when (os == "mingw32")