summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichaelSnoyman <>2014-09-12 11:01:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2014-09-12 11:01:00 (GMT)
commitb08f7109fcd23adfee28b5c9cf6dd847d9d95565 (patch)
tree0d0afed9cc9d9af3b38a516b0c2f75c20eca3f1e
parent66494212b2056c7412c8a9d0618f39779269835a (diff)
version 0.1.1.30.1.1.3
-rw-r--r--auto-update.cabal20
-rw-r--r--test/Control/AutoUpdateSpec.hs34
-rw-r--r--test/Control/ReaperSpec.hs37
-rw-r--r--test/Spec.hs1
4 files changed, 11 insertions, 81 deletions
diff --git a/auto-update.cabal b/auto-update.cabal
index 0f7abcf..2dcbb21 100644
--- a/auto-update.cabal
+++ b/auto-update.cabal
@@ -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 @@ library
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
diff --git a/test/Control/AutoUpdateSpec.hs b/test/Control/AutoUpdateSpec.hs
deleted file mode 100644
index cd3e2d7..0000000
--- a/test/Control/AutoUpdateSpec.hs
+++ /dev/null
@@ -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
diff --git a/test/Control/ReaperSpec.hs b/test/Control/ReaperSpec.hs
deleted file mode 100644
index 10e0648..0000000
--- a/test/Control/ReaperSpec.hs
+++ /dev/null
@@ -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 ()
diff --git a/test/Spec.hs b/test/Spec.hs
deleted file mode 100644
index a824f8c..0000000
--- a/test/Spec.hs
+++ /dev/null
@@ -1 +0,0 @@
-{-# OPTIONS_GHC -F -pgmF hspec-discover #-}