packages feed

tasty-quickcheck 0.10.2 → 0.10.3

raw patch · 3 files changed

+52/−14 lines, 3 filesdep ~QuickCheckdep ~optparse-applicativedep ~randomnew-uploader

Dependency ranges changed: QuickCheck, optparse-applicative, random, tagged, tasty

Files

CHANGELOG.md view
@@ -1,6 +1,12 @@ Changes ======= +Version 0.10.3+--------------++* Print Quickcheck progress using Tasty progress reporting.+  ([#311](https://github.com/UnkindPartition/tasty/pull/311)).+ Version 0.10.2 -------------- 
Test/Tasty/QuickCheck.hs view
@@ -1,5 +1,5 @@ -- | This module allows to use QuickCheck properties in tasty.-{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable #-}+{-# LANGUAGE GeneralizedNewtypeDeriving, DeriveDataTypeable, NamedFieldPuns #-} module Test.Tasty.QuickCheck   ( testProperty   , testProperties@@ -24,7 +24,10 @@ import Test.Tasty.Providers import Test.Tasty.Options import qualified Test.QuickCheck as QC-import Test.Tasty.Runners (formatMessage)+import qualified Test.QuickCheck.Test as QC+import qualified Test.QuickCheck.State as QC+import qualified Test.QuickCheck.Text as QC+import Test.Tasty.Runners (formatMessage, emptyProgress) import Test.QuickCheck hiding -- for re-export   ( quickCheck   , Args(..)@@ -47,9 +50,11 @@   , verboseCheckAll   ) +import qualified Data.Char as Char import Data.Typeable import Data.List import Text.Printf+import Text.Read (readMaybe) import Test.QuickCheck.Random (mkQCGen) import Options.Applicative (metavar) import System.Random (getStdRandom, randomR)@@ -61,7 +66,7 @@ newtype QC = QC QC.Property   deriving Typeable --- | Create a 'Test' for a QuickCheck 'QC.Testable' property+-- | Create a 'TestTree' for a QuickCheck 'QC.Testable' property testProperty :: QC.Testable a => TestName -> a -> TestTree testProperty name prop = singleTest name $ QC $ QC.property prop @@ -199,20 +204,18 @@     , Option (Proxy :: Proxy QuickCheckMaxShrinks)     ] -  run opts (QC prop) _yieldProgress = do+  run opts (QC prop) yieldProgress = do     (replaySeed, args) <- optionSetToArgs opts-     let       QuickCheckShowReplay showReplay = lookupOption opts       QuickCheckVerbose    verbose    = lookupOption opts       maxSize = QC.maxSize args-      testRunner = if verbose-                     then QC.verboseCheckWithResult-                     else QC.quickCheckWithResult       replayMsg = makeReplayMsg replaySeed maxSize      -- Quickcheck already catches exceptions, no need to do it here.-    r <- testRunner args prop+    r <- quickCheck yieldProgress+                    args+                    (if verbose then QC.verbose prop else prop)      qcOutput <- formatMessage $ QC.output r     let qcOutputNl =@@ -225,6 +228,30 @@       (if testSuccessful then testPassed else testFailed)       (qcOutputNl ++         (if putReplayInDesc then replayMsg else ""))+++-- | Like the original 'QC.quickCheck' but is reporting progress using tasty+-- callback.+--+quickCheck :: (Progress -> IO ())+           -> QC.Args+           -> QC.Property+           -> IO QC.Result+quickCheck yieldProgress args prop = do+  -- Here we rely on the fact that QuickCheck currently prints its progress to+  -- stderr and the overall status (which we don't need) to stdout+  tm <- QC.newTerminal+          (const $ pure ())+          (\progressText -> yieldProgress emptyProgress { progressPercent = parseProgress progressText })+  QC.withState args $ \ s ->+    QC.test s { QC.terminal = tm } prop+  where+    -- QuickCheck outputs something like "(15461 tests)\b\b\b\b\b\b\b\b\b\b\b\b\b"+    parseProgress :: String -> Float+    parseProgress = maybe 0 (\n -> fromIntegral (n :: Int) / fromIntegral (QC.maxSuccess args))+                  . readMaybe+                  . takeWhile Char.isDigit+                  . drop 1  successful :: QC.Result -> Bool successful r =
tasty-quickcheck.cabal view
@@ -2,9 +2,10 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                tasty-quickcheck-version:             0.10.2+version:             0.10.3 synopsis:            QuickCheck support for the Tasty test framework. description:         QuickCheck support for the Tasty test framework.+                     . license:             MIT license-file:        LICENSE author:              Roman Cheplyaka <roma@ro-che.info>@@ -19,15 +20,19 @@  Source-repository head   type:     git-  location: git://github.com/UnkindPartition/tasty.git+  location: https://github.com/UnkindPartition/tasty.git   subdir:   quickcheck  library   exposed-modules:     Test.Tasty.QuickCheck   -- other-modules:   other-extensions:    GeneralizedNewtypeDeriving, DeriveDataTypeable-  build-depends:       base >= 4.8 && < 5, tagged, tasty >= 1.0.1, random, QuickCheck >= 2.10,-                       optparse-applicative+  build-depends:       base >= 4.8 && < 5,+                       tagged < 0.9,+                       tasty >= 1.0.1 && < 1.6,+                       random < 1.3,+                       QuickCheck >= 2.10 && < 2.15,+                       optparse-applicative < 0.19    -- hs-source-dirs:   default-language:    Haskell2010@@ -46,7 +51,7 @@     test.hs   build-depends:       base >= 4.7 && < 5-    , tasty+    , tasty >= 1.5     , tasty-quickcheck     , tasty-hunit     , pcre-light