tasty-dejafu 0.4.0.0 → 0.5.0.0
raw patch · 5 files changed
+232/−48 lines, 5 filesdep ~dejafusetup-changedPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: dejafu
API changes (from Hackage documentation)
- Test.Tasty.DejaFu: Randomly :: g -> Int -> Way g
- Test.Tasty.DejaFu: Systematically :: Bounds -> Way g
- Test.Tasty.DejaFu: instance Test.Tasty.Options.IsOption (Test.DejaFu.SCT.Way System.Random.StdGen)
+ Test.Tasty.DejaFu: [Randomly] :: Way
+ Test.Tasty.DejaFu: [Systematically] :: Way
+ Test.Tasty.DejaFu: instance Test.Tasty.Options.IsOption Test.DejaFu.SCT.Way
- Test.Tasty.DejaFu: data Way g :: * -> *
+ Test.Tasty.DejaFu: data Way :: *
- Test.Tasty.DejaFu: testAutoWay :: (Eq a, Show a, RandomGen g) => Way g -> MemType -> (forall t. ConcST t a) -> TestTree
+ Test.Tasty.DejaFu: testAutoWay :: (Eq a, Show a) => Way -> MemType -> (forall t. ConcST t a) -> TestTree
- Test.Tasty.DejaFu: testAutoWayIO :: (Eq a, Show a, RandomGen g) => Way g -> MemType -> ConcIO a -> TestTree
+ Test.Tasty.DejaFu: testAutoWayIO :: (Eq a, Show a) => Way -> MemType -> ConcIO a -> TestTree
- Test.Tasty.DejaFu: testDejafuWay :: (Show a, RandomGen g) => Way g -> MemType -> (forall t. ConcST t a) -> TestName -> Predicate a -> TestTree
+ Test.Tasty.DejaFu: testDejafuWay :: Show a => Way -> MemType -> (forall t. ConcST t a) -> TestName -> Predicate a -> TestTree
- Test.Tasty.DejaFu: testDejafuWayIO :: (Show a, RandomGen g) => Way g -> MemType -> ConcIO a -> TestName -> Predicate a -> TestTree
+ Test.Tasty.DejaFu: testDejafuWayIO :: Show a => Way -> MemType -> ConcIO a -> TestName -> Predicate a -> TestTree
- Test.Tasty.DejaFu: testDejafusWay :: (Show a, RandomGen g) => Way g -> MemType -> (forall t. ConcST t a) -> [(TestName, Predicate a)] -> TestTree
+ Test.Tasty.DejaFu: testDejafusWay :: Show a => Way -> MemType -> (forall t. ConcST t a) -> [(TestName, Predicate a)] -> TestTree
- Test.Tasty.DejaFu: testDejafusWayIO :: (Show a, RandomGen g) => Way g -> MemType -> ConcIO a -> [(TestName, Predicate a)] -> TestTree
+ Test.Tasty.DejaFu: testDejafusWayIO :: Show a => Way -> MemType -> ConcIO a -> [(TestName, Predicate a)] -> TestTree
Files
- CHANGELOG.markdown +136/−0
- README.markdown +21/−0
- Setup.hs +1/−1
- Test/Tasty/DejaFu.hs +70/−40
- tasty-dejafu.cabal +4/−7
+ CHANGELOG.markdown view
@@ -0,0 +1,136 @@+Release Notes+=============++All notable changes to this project will be documented in this file.++This project is versioned according to the [Package Versioning Policy](https://pvp.haskell.org), the+*de facto* standard Haskell versioning scheme.+++0.5.0.0 [2017-04-08] (git tag: [tasty-dejafu-0.5.0.0][])+-------++https://hackage.haskell.org/package/tasty-dejafu-0.5.0.0++### Test.Tasty.DejaFu++- Due to changes in dejafu, the `Way` type no longer takes a parameter; it is now a GADT.++### Miscellaneous++- There is now a changelog.+- Every definition and instance now has a Haddock "@since" annotation.+- Only dejafu 0.6 is supported.++[tasty-dejafu-0.5.0.0]: https://github.com/barrucadu/dejafu/releases/tag/tasty-dejafu-0.5.0.0+++---------------------------------------------------------------------------------------------------+++0.4.0.0 [2017-02-21] (git tag: [tasty-dejafu-0.4.0.0][])+-------++https://hackage.haskell.org/package/tasty-dejafu-0.4.0.0++### Test.Tasty.DejaFu++- All the functions which did take a `Bounds` now take a `Way` instead and support random scheduling+ as well.+- The `Way` type from dejafu is now re-exported.+- The `IsOption` instance (and so corresponding command-line argument) for `Bounds` is gone.+- A new `IsOption` instance for `Way` (and so corresponding command-line argument):+ - "systematically": systematic testing with the default bounds.+ - "randomly": 100 executions with a fixed random seed.++### Miscellaneous++- The minimum supported version of dejafu has been increased to 0.5 (from 0.2)++[tasty-dejafu-0.4.0.0]: https://github.com/barrucadu/dejafu/releases/tag/tasty-dejafu-0.4.0.0+++---------------------------------------------------------------------------------------------------+++0.3.0.2 [2016-09-10] (git tag: [tasty-dejafu-0.3.0.2][])+-------++https://hackage.haskell.org/package/tasty-dejafu-0.3.0.2++### Miscellaneous++- Now supports concurrency 1.0.0.0 and dejafu 0.4.0.0++[tasty-dejafu-0.3.0.2]: https://github.com/barrucadu/dejafu/releases/tag/tasty-dejafu-0.3.0.2+++---------------------------------------------------------------------------------------------------+++0.3.0.1 [2016-05-26] (git tag: [tasty-dejafu-0.3.0.1][])+-------++https://hackage.haskell.org/package/tasty-dejafu-0.3.0.1++### Miscellaneous++- Now supports GHC 8.++[tasty-dejafu-0.3.0.1]: https://github.com/barrucadu/dejafu/releases/tag/tasty-dejafu-0.3.0.1+++---------------------------------------------------------------------------------------------------+++0.3.0.0 [2016-04-28] (git tag: [tasty-dejafu-0.3.0.0][])+-------++https://hackage.haskell.org/package/tasty-dejafu-0.3.0.0++### Test.Tasty.DejaFu++- New `IsTest` instances for `ConcST t (Maybe String)` and `ConcIO (Maybe String)`, with a `Just+ String` result being a test failure with an error message.+- The `Bounds` type from dejafu is now re-exported.+- New `IsOption` instances for `Bounds` and `MemType`.+- New command-line parameter to set the `MemType` parameter:+ - "sc": sequential consistency.+ - "tso": total store order.+ - "pso": partial store order.++### Miscellaneous++- Now supports dejafu 0.2 (again).++[tasty-dejafu-0.3.0.0]: https://github.com/barrucadu/dejafu/releases/tag/tasty-dejafu-0.3.0.0+++---------------------------------------------------------------------------------------------------+++0.1.1.0 [2016-04-03] (git tag: [tasty-dejafu-0.1.1.0][])+-------++**This version was never pushed to hackage, whoops!**++**This version was misnumbered! It should have been 0.2.1.0!**++### Miscellaneous++- Now supports dejafu 0.3, but drops support for dejafu 0.2.++[tasty-dejafu-0.1.1.0]: https://github.com/barrucadu/dejafu/releases/tag/tasty-dejafu-0.1.1.0+++---------------------------------------------------------------------------------------------------+++0.2.0.0 [2015-12-01] (git tag: [0.2.0.0][])+-------++https://hackage.haskell.org/package/tasty-dejafu-0.2.0.0++Initial release. Go read the API docs.++[0.2.0.0]: https://github.com/barrucadu/dejafu/releases/tag/0.2.0.0
+ README.markdown view
@@ -0,0 +1,21 @@+tasty-dejafu+============++Integration between the [dejafu][] library for concurrency testing and+[tasty][]. This lets you easily incorporate concurrency testing into+your existing test suites.++The documentation of the latest developmental version is+[available online][docs].++Contributing+------------++Bug reports, pull requests, and comments are very welcome!++Feel free to contact me on GitHub, through IRC (#haskell on freenode),+or email (mike@barrucadu.co.uk).++[docs]: https://docs.barrucadu.co.uk/tasty-dejafu+[dejafu]: https://hackage.haskell.org/package/dejafu+[tasty]: https://hackage.haskell.org/package/tasty
Setup.hs view
@@ -1,2 +1,2 @@-import Distribution.Simple+import Distribution.Simple main = defaultMain
Test/Tasty/DejaFu.hs view
@@ -56,57 +56,61 @@ , MemType(..) ) where -import Control.Monad.ST (runST)-import Data.Char (toUpper)-import Data.List (intercalate, intersperse)-import Data.Proxy (Proxy(..))-import Data.Tagged (Tagged(..))-import Data.Typeable (Typeable)-import System.Random (RandomGen, StdGen, mkStdGen)-import Test.DejaFu-import qualified Test.DejaFu.Conc as Conc-import qualified Test.DejaFu.SCT as SCT-import Test.Tasty (TestName, TestTree, testGroup)-import Test.Tasty.Options (OptionDescription(..), IsOption(..), lookupOption)-import Test.Tasty.Providers (IsTest(..), singleTest, testPassed, testFailed)+import Control.Monad.ST (runST)+import Data.Char (toUpper)+import Data.List (intercalate, intersperse)+import Data.Proxy (Proxy(..))+import Data.Tagged (Tagged(..))+import Data.Typeable (Typeable)+import System.Random (StdGen, mkStdGen)+import Test.DejaFu+import qualified Test.DejaFu.Conc as Conc+import qualified Test.DejaFu.SCT as SCT+import Test.Tasty (TestName, TestTree, testGroup)+import Test.Tasty.Options (IsOption(..), OptionDescription(..),+ lookupOption)+import Test.Tasty.Providers (IsTest(..), singleTest, testFailed,+ testPassed) -- Can't put the necessary forall in the @IsTest ConcST t@ -- instance :(-import Unsafe.Coerce (unsafeCoerce)+import Unsafe.Coerce (unsafeCoerce) -runSCTst :: RandomGen g => Way g -> MemType -> (forall t. Conc.ConcST t a) -> [(Either Failure a, Conc.Trace)]+runSCTst :: Way -> MemType -> (forall t. Conc.ConcST t a) -> [(Either Failure a, Conc.Trace)] runSCTst way memtype conc = runST (SCT.runSCT way memtype conc) -runSCTio :: RandomGen g => Way g -> MemType -> Conc.ConcIO a -> IO [(Either Failure a, Conc.Trace)]+runSCTio :: Way -> MemType -> Conc.ConcIO a -> IO [(Either Failure a, Conc.Trace)] runSCTio = SCT.runSCT -------------------------------------------------------------------------------- -- Unit testing +-- | @since 0.3.0.0 instance Typeable t => IsTest (Conc.ConcST t (Maybe String)) where testOptions = Tagged concOptions run options conc callback = do let memtype = lookupOption options :: MemType- let way = lookupOption options :: Way StdGen+ let way = lookupOption options :: Way let runSCTst' :: Conc.ConcST t (Maybe String) -> [(Either Failure (Maybe String), Conc.Trace)] runSCTst' = unsafeCoerce $ runSCTst way memtype let traces = runSCTst' conc run options (ConcTest traces assertableP) callback +-- | @since 0.3.0.0 instance IsTest (Conc.ConcIO (Maybe String)) where testOptions = Tagged concOptions run options conc callback = do let memtype = lookupOption options- let way = lookupOption options :: Way StdGen+ let way = lookupOption options let traces = runSCTio way memtype conc run options (ConcIOTest traces assertableP) callback concOptions :: [OptionDescription] concOptions = [ Option (Proxy :: Proxy MemType)- , Option (Proxy :: Proxy (Way StdGen))+ , Option (Proxy :: Proxy Way) ] assertableP :: Predicate (Maybe String)@@ -114,6 +118,7 @@ Right (Just _) -> False _ -> True +-- | @since 0.3.0.0 instance IsOption MemType where defaultValue = defaultMemType parseValue = shortName . map toUpper where@@ -124,7 +129,8 @@ optionName = Tagged "memory-model" optionHelp = Tagged "The memory model to use. This should be one of \"sc\", \"tso\", or \"pso\"." -instance IsOption (Way StdGen) where+-- | @since 0.5.0.0+instance IsOption Way where defaultValue = defaultWay parseValue = shortName . map toUpper where shortName "SYSTEMATICALLY" = Just (Systematically defaultBounds)@@ -142,6 +148,8 @@ -- This uses the 'Conc' monad for testing, which is an instance of -- 'MonadConc'. If you need to test something which also uses -- 'MonadIO', use 'testAutoIO'.+--+-- @since 0.2.0.0 testAuto :: (Eq a, Show a) => (forall t. Conc.ConcST t a) -- ^ The computation to test@@ -150,8 +158,10 @@ -- | Variant of 'testAuto' which tests a computation under a given -- execution way and memory model.-testAutoWay :: (Eq a, Show a, RandomGen g)- => Way g+--+-- @since 0.5.0.0+testAutoWay :: (Eq a, Show a)+ => Way -- ^ How to execute the concurrent program. -> MemType -- ^ The memory model to use for non-synchronised @CRef@ operations.@@ -161,12 +171,16 @@ testAutoWay way memtype conc = testDejafusWay way memtype conc autocheckCases -- | Variant of 'testAuto' for computations which do 'IO'.+--+-- @since 0.2.0.0 testAutoIO :: (Eq a, Show a) => Conc.ConcIO a -> TestTree testAutoIO = testAutoWayIO defaultWay defaultMemType -- | Variant of 'testAutoWay' for computations which do 'IO'.-testAutoWayIO :: (Eq a, Show a, RandomGen g)- => Way g -> MemType -> Conc.ConcIO a -> TestTree+--+-- @since 0.5.0.0+testAutoWayIO :: (Eq a, Show a)+ => Way -> MemType -> Conc.ConcIO a -> TestTree testAutoWayIO way memtype concio = testDejafusWayIO way memtype concio autocheckCases @@ -179,6 +193,8 @@ ] -- | Check that a predicate holds.+--+-- @since 0.2.0.0 testDejafu :: Show a => (forall t. Conc.ConcST t a) -- ^ The computation to test@@ -191,8 +207,10 @@ -- | Variant of 'testDejafu' which takes a way to execute the program -- and a memory model.-testDejafuWay :: (Show a, RandomGen g)- => Way g+--+-- @since 0.5.0.0+testDejafuWay :: Show a+ => Way -- ^ How to execute the concurrent program. -> MemType -- ^ The memory model to use for non-synchronised @CRef@ operations.@@ -209,6 +227,8 @@ -- | 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 0.2.0.0 testDejafus :: Show a => (forall t. Conc.ConcST t a) -- ^ The computation to test@@ -219,8 +239,10 @@ -- | Variant of 'testDejafus' which takes a way to execute the program -- and a memory model.-testDejafusWay :: (Show a, RandomGen g)- => Way g+--+-- @since 0.5.0.0+testDejafusWay :: Show a+ => Way -- ^ How to execute the concurrent program. -> MemType -- ^ The memory model to use for non-synchronised @CRef@ operations.@@ -232,22 +254,30 @@ testDejafusWay = testst -- | Variant of 'testDejafu' for computations which do 'IO'.+--+-- @since 0.2.0.0 testDejafuIO :: Show a => Conc.ConcIO a -> TestName -> Predicate a -> TestTree testDejafuIO = testDejafuWayIO defaultWay defaultMemType -- | Variant of 'testDejafuWay' for computations which do 'IO'.-testDejafuWayIO :: (Show a, RandomGen g)- => Way g -> MemType -> Conc.ConcIO a -> TestName -> Predicate a -> TestTree+--+-- @since 0.5.0.0+testDejafuWayIO :: Show a+ => Way -> MemType -> Conc.ConcIO a -> TestName -> Predicate a -> TestTree testDejafuWayIO way memtype concio name p = testDejafusWayIO way memtype concio [(name, p)] -- | Variant of 'testDejafus' for computations which do 'IO'.+--+-- @since 0.2.0.0 testDejafusIO :: Show a => Conc.ConcIO a -> [(TestName, Predicate a)] -> TestTree testDejafusIO = testDejafusWayIO defaultWay defaultMemType -- | Variant of 'dejafusWay' for computations which do 'IO'.-testDejafusWayIO :: (Show a, RandomGen g)- => Way g -> MemType -> Conc.ConcIO a -> [(TestName, Predicate a)] -> TestTree+--+-- @since 0.5.0.0+testDejafusWayIO :: Show a+ => Way -> MemType -> Conc.ConcIO a -> [(TestName, Predicate a)] -> TestTree testDejafusWayIO = testio --------------------------------------------------------------------------------@@ -262,23 +292,23 @@ deriving Typeable instance IsTest ConcTest where- testOptions = return []+ testOptions = pure [] run _ (ConcTest traces p) _ = let err = showErr $ p traces- in return $ if null err then testPassed "" else testFailed err+ in pure (if null err then testPassed "" else testFailed err) instance IsTest ConcIOTest where- testOptions = return []+ testOptions = pure [] run _ (ConcIOTest iotraces p) _ = do traces <- iotraces let err = showErr $ p traces- return $ if null err then testPassed "" else testFailed err+ pure (if null err then testPassed "" else testFailed err) -- | Produce a Tasty 'TestTree' from a Deja Fu test.-testst :: (Show a, RandomGen g)- => Way g -> MemType -> (forall t. Conc.ConcST t a) -> [(TestName, Predicate a)] -> TestTree+testst :: Show a+ => Way -> MemType -> (forall t. Conc.ConcST t a) -> [(TestName, Predicate a)] -> TestTree testst way memtype conc tests = case map toTest tests of [t] -> t ts -> testGroup "Deja Fu Tests" ts@@ -289,8 +319,8 @@ traces = runSCTst way memtype conc -- | Produce a Tasty 'Test' from an IO-using Deja Fu test.-testio :: (Show a, RandomGen g)- => Way g -> MemType -> Conc.ConcIO a -> [(TestName, Predicate a)] -> TestTree+testio :: Show a+ => Way -> MemType -> Conc.ConcIO a -> [(TestName, Predicate a)] -> TestTree testio way memtype concio tests = case map toTest tests of [t] -> t ts -> testGroup "Deja Fu Tests" ts
tasty-dejafu.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: tasty-dejafu-version: 0.4.0.0+version: 0.5.0.0 synopsis: Deja Fu support for the Tasty test framework. description:@@ -11,9 +11,6 @@ <https://hackage.haskell.org/package/tasty tasty>. This lets you easily incorporate concurrency testing into your existing test suites.- .- See the <https://github.com/barrucadu/dejafu README> for more- details. homepage: https://github.com/barrucadu/dejafu license: MIT@@ -23,7 +20,7 @@ -- copyright: category: Testing build-type: Simple--- extra-source-files: +extra-source-files: README.markdown CHANGELOG.markdown cabal-version: >=1.10 source-repository head@@ -33,14 +30,14 @@ source-repository this type: git location: https://github.com/barrucadu/dejafu.git- tag: tasty-dejafu-0.4.0.0+ tag: tasty-dejafu-0.5.0.0 library exposed-modules: Test.Tasty.DejaFu -- other-modules: -- other-extensions: build-depends: base >=4.8 && <5- , dejafu >=0.5 && <0.6+ , dejafu >=0.6 && <0.7 , random >=1.0 && <1.2 , tagged >=0.8 && <0.9 , tasty >=0.10 && <0.12