From 599ce8d9e28e94d50c285bec1118b6de81017419 Mon Sep 17 00:00:00 2001 From: Felix Paulusma Date: Sun, 3 Nov 2024 15:39:37 +0100 Subject: [PATCH] seeing as 'threadDelay' doesn't guarantee immediate pickup, we shouldn't test that. Did extend the test to verify a trigger does at least restart the timer --- auto-update/test/Control/DebounceSpec.hs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/auto-update/test/Control/DebounceSpec.hs b/auto-update/test/Control/DebounceSpec.hs index 29ad1e8d5..748d544ed 100644 --- a/auto-update/test/Control/DebounceSpec.hs +++ b/auto-update/test/Control/DebounceSpec.hs @@ -153,6 +153,7 @@ spec = describe "mkDebounce" $ do threadDelay 500_000 readIORef ref `shouldReturn` 0 + before2nd <- getMonotonicTime debounced readIORef ref `shouldReturn` 0 threadDelay 500_000 @@ -164,10 +165,10 @@ spec = describe "mkDebounce" $ do waitUntil 1 $ readIORef ref `shouldReturn` 1 end <- getMonotonicTime - assertBool "Took less than 1.5 sec" $ + assertBool "Took less than 1 sec after retrigger" $ + end - before2nd > 1 + assertBool "Took less than 1.5 sec total" $ end - start > 1.5 - assertBool "Took more than 1.6 sec" $ - end - start < 1.6 -- | Make a controllable delay function getWaitAction :: IO (p -> IO (), IO ())