tasty-dejafu 1.2.1.0 → 2.0.0.0
raw patch · 3 files changed
+96/−83 lines, 3 filesdep ~dejafuPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: dejafu
API changes (from Hackage documentation)
- Test.Tasty.DejaFu: testDejafuDiscard :: Show b => (Either Condition a -> Maybe Discard) -> Way -> MemType -> String -> ProPredicate a b -> ConcIO a -> TestTree
- Test.Tasty.DejaFu: testDejafusDiscard :: Show b => (Either Condition a -> Maybe Discard) -> Way -> MemType -> [(TestName, ProPredicate a b)] -> ConcIO a -> TestTree
+ Test.Tasty.DejaFu: data Basic
+ Test.Tasty.DejaFu: data Invariant (n :: Type -> Type) a
+ Test.Tasty.DejaFu: data Program pty (n :: Type -> Type) a
+ Test.Tasty.DejaFu: data WithSetup x
+ Test.Tasty.DejaFu: data WithSetupAndTeardown x y
+ Test.Tasty.DejaFu: inspectIORef :: () => ModelIORef n a -> Invariant n a
+ Test.Tasty.DejaFu: inspectMVar :: () => ModelMVar n a -> Invariant n (Maybe a)
+ Test.Tasty.DejaFu: inspectTVar :: () => ModelTVar n a -> Invariant n a
+ Test.Tasty.DejaFu: registerInvariant :: () => Invariant n a -> Program Basic n ()
+ Test.Tasty.DejaFu: type ConcIO = ConcT IO
+ Test.Tasty.DejaFu: type ConcT = Program Basic
+ Test.Tasty.DejaFu: withSetup :: () => Program Basic n x -> (x -> Program Basic n a) -> Program (WithSetup x) n a
+ Test.Tasty.DejaFu: withSetupAndTeardown :: () => Program Basic n x -> (x -> Either Condition y -> Program Basic n a) -> (x -> Program Basic n y) -> Program (WithSetupAndTeardown x y) n a
+ Test.Tasty.DejaFu: withTeardown :: () => (x -> Either Condition y -> Program Basic n a) -> Program (WithSetup x) n y -> Program (WithSetupAndTeardown x y) n a
- Test.Tasty.DejaFu: testAuto :: (Eq a, Show a) => ConcIO a -> TestTree
+ Test.Tasty.DejaFu: testAuto :: (Eq a, Show a) => Program pty IO a -> TestTree
- Test.Tasty.DejaFu: testAutoWay :: (Eq a, Show a) => Way -> MemType -> ConcIO a -> TestTree
+ Test.Tasty.DejaFu: testAutoWay :: (Eq a, Show a) => Way -> MemType -> Program pty IO a -> TestTree
- Test.Tasty.DejaFu: testAutoWithSettings :: (Eq a, Show a) => Settings IO a -> ConcIO a -> TestTree
+ Test.Tasty.DejaFu: testAutoWithSettings :: (Eq a, Show a) => Settings IO a -> Program pty IO a -> TestTree
- Test.Tasty.DejaFu: testDejafu :: Show b => TestName -> ProPredicate a b -> ConcIO a -> TestTree
+ Test.Tasty.DejaFu: testDejafu :: Show b => TestName -> ProPredicate a b -> Program pty IO a -> TestTree
- Test.Tasty.DejaFu: testDejafuWay :: Show b => Way -> MemType -> TestName -> ProPredicate a b -> ConcIO a -> TestTree
+ Test.Tasty.DejaFu: testDejafuWay :: Show b => Way -> MemType -> TestName -> ProPredicate a b -> Program pty IO a -> TestTree
- Test.Tasty.DejaFu: testDejafuWithSettings :: Show b => Settings IO a -> TestName -> ProPredicate a b -> ConcIO a -> TestTree
+ Test.Tasty.DejaFu: testDejafuWithSettings :: Show b => Settings IO a -> TestName -> ProPredicate a b -> Program pty IO a -> TestTree
- Test.Tasty.DejaFu: testDejafus :: Show b => [(TestName, ProPredicate a b)] -> ConcIO a -> TestTree
+ Test.Tasty.DejaFu: testDejafus :: Show b => [(TestName, ProPredicate a b)] -> Program pty IO a -> TestTree
- Test.Tasty.DejaFu: testDejafusWay :: Show b => Way -> MemType -> [(TestName, ProPredicate a b)] -> ConcIO a -> TestTree
+ Test.Tasty.DejaFu: testDejafusWay :: Show b => Way -> MemType -> [(TestName, ProPredicate a b)] -> Program pty IO a -> TestTree
- Test.Tasty.DejaFu: testDejafusWithSettings :: Show b => Settings IO a -> [(TestName, ProPredicate a b)] -> ConcIO a -> TestTree
+ Test.Tasty.DejaFu: testDejafusWithSettings :: Show b => Settings IO a -> [(TestName, ProPredicate a b)] -> Program pty IO a -> TestTree
Files
- CHANGELOG.rst +54/−0
- Test/Tasty/DejaFu.hs +39/−80
- tasty-dejafu.cabal +3/−3
CHANGELOG.rst view
@@ -7,6 +7,60 @@ .. _PVP: https://pvp.haskell.org/ +2.0.0.0 (2019-02-12)+--------------------++* Git: :tag:`tasty-dejafu-2.0.0.0`+* Hackage: :hackage:`tasty-dejafu-2.0.0.0`++Added+~~~~~++* Re-exports for the ``Program`` types and their constructors:+ * ``Test.Tasty.DejaFu.Program``+ * ``Test.Tasty.DejaFu.Basic``+ * ``Test.Tasty.DejaFu.ConcT``+ * ``Test.Tasty.DejaFu.ConcIO``+ * ``Test.Tasty.DejaFu.WithSetup``+ * ``Test.Tasty.DejaFu.WithSetupAndTeardown``+ * ``Test.Tasty.DejaFu.withSetup``+ * ``Test.Tasty.DejaFu.withTeardown``+ * ``Test.Tasty.DejaFu.withSetupAndTeardown``++* Re-exports for the ``Invariant`` type and its functions:+ * ``Test.Tasty.DejaFu.Invariant``+ * ``Test.Tasty.DejaFu.registerInvariant``+ * ``Test.Tasty.DejaFu.inspectIORef``+ * ``Test.Tasty.DejaFu.inspectMVar``+ * ``Test.Tasty.DejaFu.inspectTVar``++Changes+~~~~~~~++* Functions which took a ``ConcIO`` now take a ``Program pty IO``:+ * ``Test.Tasty.DejaFu.testAuto``+ * ``Test.Tasty.DejaFu.testAutoWay``+ * ``Test.Tasty.DejaFu.testAutoWithSettings``+ * ``Test.Tasty.DejaFu.testDejafu``+ * ``Test.Tasty.DejaFu.testDejafuWay``+ * ``Test.Tasty.DejaFu.testDejafuWithSettings``+ * ``Test.Tasty.DejaFu.testDejafus``+ * ``Test.Tasty.DejaFu.testDejafusWay``+ * ``Test.Tasty.DejaFu.testDejafusWithSettings``++Removed+~~~~~~~++* The deprecated functions:+ * ``Test.Tasty.DejaFu.testDejafuDiscard``+ * ``Test.Tasty.DejaFu.testDejafusDiscard``++Miscellaneous+~~~~~~~~~~~~~++* The lower bound on :hackage:`dejafu` is >=2.0.++ 1.2.1.0 (2019-01-20) --------------------
Test/Tasty/DejaFu.hs view
@@ -1,17 +1,15 @@-{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-}-{-# LANGUAGE TypeSynonymInstances #-} -- | -- Module : Test.Tasty.DejaFu--- Copyright : (c) 2015--2018 Michael Walker+-- Copyright : (c) 2015--2019 Michael Walker -- License : MIT -- Maintainer : Michael Walker <mike@barrucadu.co.uk> -- Stability : stable--- Portability : FlexibleContexts, FlexibleInstances, GADTs, LambdaCase, TypeSynonymInstances+-- Portability : FlexibleContexts, FlexibleInstances, GADTs, LambdaCase -- -- This module allows using Deja Fu predicates with Tasty to test the -- behaviour of concurrent systems.@@ -43,7 +41,24 @@ , Condition , Predicate , ProPredicate(..)+ -- *** Settings , module Test.DejaFu.Settings+ -- *** Expressing concurrent programs+ , Program+ , Basic+ , ConcT+ , ConcIO+ , WithSetup+ , WithSetupAndTeardown+ , withSetup+ , withTeardown+ , withSetupAndTeardown+ -- *** Invariants+ , Invariant+ , registerInvariant+ , inspectIORef+ , inspectMVar+ , inspectTVar -- * Refinement property testing , testProperty@@ -58,10 +73,6 @@ , R.refines, (R.=>=) , R.strictlyRefines, (R.->-) , R.equivalentTo, (R.===)-- -- * Deprecated- , testDejafuDiscard- , testDejafusDiscard ) where import Data.Char (toUpper)@@ -83,17 +94,6 @@ import Test.Tasty.Providers (IsTest(..), singleTest, testFailed, testPassed) -showCondition :: Condition -> String-#if MIN_VERSION_dejafu(1,12,0)-showCondition = Conc.showCondition-#else--- | An alias for 'Failure'.------ @since 1.2.1.0-type Condition = Failure-showCondition = Conc.showFail-#endif- -------------------------------------------------------------------------------- -- Tasty-style unit testing @@ -146,9 +146,9 @@ -- | Automatically test a computation. In particular, look for -- deadlocks, uncaught exceptions, and multiple return values. ----- @since 1.0.0.0+-- @since 2.0.0.0 testAuto :: (Eq a, Show a)- => Conc.ConcIO a+ => Program pty IO a -- ^ The computation to test. -> TestTree testAuto = testAutoWithSettings defaultSettings@@ -156,24 +156,24 @@ -- | Variant of 'testAuto' which tests a computation under a given -- execution way and memory model. ----- @since 1.0.0.0+-- @since 2.0.0.0 testAutoWay :: (Eq a, Show a) => Way -- ^ How to execute the concurrent program. -> MemType -- ^ The memory model to use for non-synchronised @IORef@ operations.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> TestTree testAutoWay way = testAutoWithSettings . fromWayAndMemType way -- | Variant of 'testAuto' which takes a settings record. ----- @since 1.1.0.0+-- @since 2.0.0.0 testAutoWithSettings :: (Eq a, Show a) => Settings IO a -- ^ The SCT settings.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> TestTree testAutoWithSettings settings = testDejafusWithSettings settings@@ -184,13 +184,13 @@ -- | Check that a predicate holds. ----- @since 1.0.0.0+-- @since 2.0.0.0 testDejafu :: Show b => TestName -- ^ The name of the test. -> ProPredicate a b -- ^ The predicate to check.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> TestTree testDejafu = testDejafuWithSettings defaultSettings@@ -198,7 +198,7 @@ -- | Variant of 'testDejafu' which takes a way to execute the program -- and a memory model. ----- @since 1.0.0.0+-- @since 2.0.0.0 testDejafuWay :: Show b => Way -- ^ How to execute the concurrent program.@@ -208,14 +208,14 @@ -- ^ The name of the test. -> ProPredicate a b -- ^ The predicate to check.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> TestTree testDejafuWay way = testDejafuWithSettings . fromWayAndMemType way -- | Variant of 'testDejafu' which takes a settings record. ----- @since 1.1.0.0+-- @since 2.0.0.0 testDejafuWithSettings :: Show b => Settings IO a -- ^ The settings record@@ -223,41 +223,20 @@ -- ^ The name of the test. -> ProPredicate a b -- ^ The predicate to check.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> TestTree testDejafuWithSettings settings name p = testDejafusWithSettings settings [(name, p)] --- | Variant of 'testDejafuWay' which can selectively discard results.------ @since 1.0.0.0-testDejafuDiscard :: Show b- => (Either Condition a -> Maybe Discard)- -- ^ Selectively discard results.- -> Way- -- ^ How to execute the concurrent program.- -> MemType- -- ^ The memory model to use for non-synchronised @IORef@ operations.- -> String- -- ^ The name of the test.- -> ProPredicate a b- -- ^ The predicate to check.- -> Conc.ConcIO a- -- ^ The computation to test.- -> TestTree-testDejafuDiscard discard way =- testDejafuWithSettings . set ldiscard (Just discard) . fromWayAndMemType way-{-# DEPRECATED testDejafuDiscard "Use testDejafuWithSettings instead" #-}- -- | Variant of 'testDejafu' which takes a collection of predicates to -- test. This will share work between the predicates, rather than -- running the concurrent computation many times for each predicate. ----- @since 1.0.0.0+-- @since 2.0.0.0 testDejafus :: Show b => [(TestName, ProPredicate a b)] -- ^ The list of predicates (with names) to check.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> TestTree testDejafus = testDejafusWithSettings defaultSettings@@ -265,7 +244,7 @@ -- | Variant of 'testDejafus' which takes a way to execute the program -- and a memory model. ----- @since 1.0.0.0+-- @since 2.0.0.0 testDejafusWay :: Show b => Way -- ^ How to execute the concurrent program.@@ -273,45 +252,25 @@ -- ^ The memory model to use for non-synchronised @IORef@ operations. -> [(TestName, ProPredicate a b)] -- ^ The list of predicates (with names) to check.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> TestTree testDejafusWay way = testDejafusWithSettings . fromWayAndMemType way -- | Variant of 'testDejafus' which takes a settings record. ----- @since 1.1.0.0+-- @since 2.0.0.0 testDejafusWithSettings :: Show b => Settings IO a -- ^ The SCT settings. -> [(TestName, ProPredicate a b)] -- ^ The list of predicates (with names) to check.- -> Conc.ConcIO a+ -> Program pty IO a -- ^ The computation to test. -> TestTree testDejafusWithSettings = testconc --- | Variant of 'testDejafusWay' which can selectively discard--- results, beyond what each predicate already discards.------ @since 1.0.1.0-testDejafusDiscard :: Show b- => (Either Condition a -> Maybe Discard)- -- ^ Selectively discard results.- -> Way- -- ^ How to execute the concurrent program.- -> MemType- -- ^ The memory model to use for non-synchronised @IORef@ operations.- -> [(TestName, ProPredicate a b)]- -- ^ The list of predicates (with names) to check.- -> Conc.ConcIO a- -- ^ The computation to test.- -> TestTree-testDejafusDiscard discard way =- testDejafusWithSettings . set ldiscard (Just discard) . fromWayAndMemType way-{-# DEPRECATED testDejafusDiscard "Use testDejafusWithSettings instead" #-} - ------------------------------------------------------------------------------- -- Refinement property testing @@ -384,7 +343,7 @@ testconc :: Show b => Settings IO a -> [(TestName, ProPredicate a b)]- -> Conc.ConcIO a+ -> Program pty IO a -> TestTree testconc settings tests concio = case map toTest tests of [t] -> t@@ -410,7 +369,7 @@ msg = if null (_failureMsg res) then "" else _failureMsg res ++ "\n" - failures = intersperse "" . map (\(r, t) -> indent $ either showCondition show r ++ " " ++ Conc.showTrace t) . take 5 $ _failures res+ failures = intersperse "" . map (\(r, t) -> indent $ either Conc.showCondition show r ++ " " ++ Conc.showTrace t) . take 5 $ _failures res rest = if moreThan (_failures res) 5 then "\n\t..." else ""
tasty-dejafu.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: tasty-dejafu-version: 1.2.1.0+version: 2.0.0.0 synopsis: Deja Fu support for the Tasty test framework. description:@@ -30,14 +30,14 @@ source-repository this type: git location: https://github.com/barrucadu/dejafu.git- tag: tasty-dejafu-1.2.1.0+ tag: tasty-dejafu-2.0.0.0 library exposed-modules: Test.Tasty.DejaFu -- other-modules: -- other-extensions: build-depends: base >=4.9 && <5- , dejafu >=1.5 && <1.13+ , dejafu >=2.0 && <2.1 , random >=1.0 && <1.2 , tagged >=0.8 && <0.9 , tasty >=0.10 && <1.3