auto-update 0.1.1.2 → 0.1.1.3
raw patch · 4 files changed
+11/−81 lines, 4 filesdep −auto-updatedep −hspecdep ~basePVP ok
version bump matches the API change (PVP)
Dependencies removed: auto-update, hspec
Dependency ranges changed: base
API changes (from Hackage documentation)
Files
- auto-update.cabal +11/−9
- test/Control/AutoUpdateSpec.hs +0/−34
- test/Control/ReaperSpec.hs +0/−37
- test/Spec.hs +0/−1
auto-update.cabal view
@@ -1,5 +1,5 @@ name: auto-update-version: 0.1.1.2+version: 0.1.1.3 synopsis: Efficiently run periodic, on-demand actions description: A common problem is the desire to have an action run at a scheduled interval, but only if it is needed. For example, instead of having every web request result in a new @getCurrentTime@ call, we'd like to have a single worker thread run every second, updating an @IORef@. However, if the request frequency is less than once per second, this is a pessimization, and worse, kills idle GC.@@ -22,11 +22,13 @@ build-depends: base >= 4 && < 5 default-language: Haskell2010 -test-suite spec- main-is: Spec.hs- other-modules: Control.AutoUpdateSpec- Control.ReaperSpec- hs-source-dirs: test- type: exitcode-stdio-1.0- build-depends: base, auto-update, hspec- default-language: Haskell2010+-- Test suite is currently not robust enough, gives too many false negatives.++-- test-suite spec+-- main-is: Spec.hs+-- other-modules: Control.AutoUpdateSpec+-- Control.ReaperSpec+-- hs-source-dirs: test+-- type: exitcode-stdio-1.0+-- build-depends: base, auto-update, hspec+-- default-language: Haskell2010
− test/Control/AutoUpdateSpec.hs
@@ -1,34 +0,0 @@-module Control.AutoUpdateSpec (spec) where--import Test.Hspec-import Test.Hspec.QuickCheck-import Data.IORef-import Control.Concurrent (threadDelay)-import Control.Monad (replicateM_, forM_)-import Control.AutoUpdate--spec :: Spec-spec = do- prop "incrementer" $ \st' -> do- let st = abs st' `mod` 10000- ref <- newIORef 0- next <- mkAutoUpdate defaultUpdateSettings- { updateAction = atomicModifyIORef ref $ \i ->- let i' = succ i in i' `seq` (i', i')- , updateSpawnThreshold = st- , updateFreq = 10000- }-- forM_ [1..st + 1] $ \i -> do- j <- next- j `shouldBe` i-- replicateM_ 50 $ do- i <- next- i `shouldBe` st + 2-- threadDelay 60000- last1 <- readIORef ref- threadDelay 20000- last2 <- readIORef ref- last2 `shouldBe` last1
− test/Control/ReaperSpec.hs
@@ -1,37 +0,0 @@-module Control.ReaperSpec (spec) where--import Control.Reaper-import Control.Concurrent-import Test.Hspec-import Test.Hspec.QuickCheck-import Data.IORef--type Item = (Int, IORef Int)--action = mkListAction $ \(i, ref) -> do- modifyIORef ref succ- return $ if i > 1- then Just (pred i, ref)- else Nothing--spec :: Spec-spec = prop "works" $ \is -> do- reaper <- mkReaper defaultReaperSettings- { reaperAction = action- , reaperDelay = 1000- }-- let mkTestCase i = do- ref <- newIORef 0- let expected = (abs i `mod` 10) + 1- reaperAdd reaper (expected, ref)- return (expected, ref)- testCases <- mapM mkTestCase is-- let test (expected, ref) = do- actual <- readIORef ref- actual `shouldBe` (expected :: Int)- threadDelay 100000- mapM_ test testCases- [] <- reaperRead reaper- return ()
− test/Spec.hs
@@ -1,1 +0,0 @@-{-# OPTIONS_GHC -F -pgmF hspec-discover #-}