packages feed

hspec-core 2.7.2 → 2.7.3

raw patch · 9 files changed

+100/−4 lines, 9 filesPVP: major bump suggested

API removals or changes: PVP suggests a major version bump

API changes (from Hackage documentation)

+ Test.Hspec.Core.Runner: [configRandomize] :: Config -> Bool
- Test.Hspec.Core.Runner: Config :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Maybe FilePath -> Bool -> Bool -> Maybe (Path -> Bool) -> Maybe (Path -> Bool) -> Maybe Integer -> Maybe Int -> Maybe Int -> Maybe Int -> Int -> ColorMode -> Bool -> Maybe Formatter -> Bool -> Either Handle FilePath -> Maybe Int -> Config
+ Test.Hspec.Core.Runner: Config :: Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Bool -> Maybe FilePath -> Bool -> Bool -> Maybe (Path -> Bool) -> Maybe (Path -> Bool) -> Maybe Integer -> Maybe Int -> Maybe Int -> Maybe Int -> Int -> ColorMode -> Bool -> Maybe Formatter -> Bool -> Either Handle FilePath -> Maybe Int -> Config

Files

hspec-core.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:             hspec-core-version:          2.7.2+version:          2.7.3 license:          MIT license-file:     LICENSE copyright:        (c) 2011-2019 Simon Hengel,@@ -71,6 +71,7 @@       Test.Hspec.Core.Formatters.Monad       Test.Hspec.Core.QuickCheckUtil       Test.Hspec.Core.Runner.Eval+      Test.Hspec.Core.Shuffle       Test.Hspec.Core.Spec.Monad       Test.Hspec.Core.Timer       Test.Hspec.Core.Tree@@ -132,6 +133,7 @@       Test.Hspec.Core.QuickCheckUtil       Test.Hspec.Core.Runner       Test.Hspec.Core.Runner.Eval+      Test.Hspec.Core.Shuffle       Test.Hspec.Core.Spec       Test.Hspec.Core.Spec.Monad       Test.Hspec.Core.Timer@@ -156,6 +158,7 @@       Test.Hspec.Core.QuickCheckUtilSpec       Test.Hspec.Core.Runner.EvalSpec       Test.Hspec.Core.RunnerSpec+      Test.Hspec.Core.ShuffleSpec       Test.Hspec.Core.SpecSpec       Test.Hspec.Core.TimerSpec       Test.Hspec.Core.UtilSpec
src/Test/Hspec/Core/Config/Options.hs view
@@ -37,6 +37,7 @@ , configFailOnFocused :: Bool , configPrintCpuTime :: Bool , configFastFail :: Bool+, configRandomize :: Bool , configFailureReport :: Maybe FilePath , configRerun :: Bool , configRerunAllOnSuccess :: Bool@@ -67,6 +68,7 @@ , configFailOnFocused = False , configPrintCpuTime = False , configFastFail = False+, configRandomize = False , configFailureReport = Nothing , configRerun = False , configRerunAllOnSuccess = False@@ -199,10 +201,13 @@   , mkFlag "focused-only" setFocusedOnly "do not run anything, unless there are focused spec items"   , mkFlag "fail-on-focused" setFailOnFocused "fail on focused spec items"   , mkFlag "fail-fast" setFastFail "abort on first failure"+  , mkFlag "randomize" setRandomize "randomize execution order"   ] ++ [     Option "r" ["rerun"] (NoArg  setRerun) "rerun all examples that failed in the previous test run (only works in combination with --failure-report or in GHCi)"   , mkOption [] "failure-report" (Arg "FILE" return setFailureReport) "read/write a failure report for use with --rerun"   , Option [] ["rerun-all-on-success"] (NoArg setRerunAllOnSuccess) "run the whole test suite after a previously failing rerun succeeds for the first time (only works in combination with --rerun)"++   , mkOption "j" "jobs" (Arg "N" readMaxJobs setMaxJobs) "run at most N parallelizable tests simultaneously (default: number of available processors)"   ]   where@@ -229,6 +234,9 @@      setFastFail :: Bool -> Config -> Config     setFastFail value config = config {configFastFail = value}++    setRandomize :: Bool -> Config -> Config+    setRandomize value config = config {configRandomize = value}      setRerun        = set $ \config -> config {configRerun = True}     setRerunAllOnSuccess = set $ \config -> config {configRerunAllOnSuccess = True}
src/Test/Hspec/Core/Runner.hs view
@@ -39,6 +39,9 @@ import           System.Environment (getArgs, withArgs) import           System.Exit import qualified Control.Exception as E+import           System.Random+import           Control.Monad.ST+import           Data.STRef  import           System.Console.ANSI (hHideCursor, hShowCursor) import qualified Test.QuickCheck as QC@@ -50,6 +53,7 @@ import           Test.Hspec.Core.Formatters.Internal import           Test.Hspec.Core.FailureReport import           Test.Hspec.Core.QuickCheckUtil+import           Test.Hspec.Core.Shuffle  import           Test.Hspec.Core.Runner.Eval @@ -219,8 +223,11 @@     let       focusedSpec = focusSpec config (failFocusedItems config spec)       params = Params (configQuickCheckArgs config) (configSmallCheckDepth config)+      randomize+        | configRandomize config = randomizeForest seed+        | otherwise = id -    filteredSpec <- filterSpecs config . mapMaybe (toEvalTree params) . applyDryRun config <$> runSpecM focusedSpec+    filteredSpec <- randomize . filterSpecs config . mapMaybe (toEvalTree params) . applyDryRun config <$> runSpecM focusedSpec      (total, failures) <- withHiddenCursor useColor h $ do       let@@ -306,3 +313,14 @@ instance Semigroup Summary where   (Summary x1 x2) <> (Summary y1 y2) = Summary (x1 + y1) (x2 + y2) #endif++randomizeForest :: Integer -> [Tree c a] -> [Tree c a]+randomizeForest seed t = runST $ do+  ref <- newSTRef (mkStdGen $ fromIntegral seed)+  mapM (randomizeTree ref) t++randomizeTree :: STRef s StdGen -> Tree c a -> ST s (Tree c a)+randomizeTree ref t = case t of+  Node d xs -> Node d <$> shuffle ref xs+  NodeWithCleanup c xs -> NodeWithCleanup c <$> shuffle ref xs+  Leaf {} -> return t
+ src/Test/Hspec/Core/Shuffle.hs view
@@ -0,0 +1,34 @@+{-# LANGUAGE CPP #-}+module Test.Hspec.Core.Shuffle (+  shuffle+#ifdef TEST+, mkArray+#endif+) where++import           Prelude ()+import           Test.Hspec.Core.Compat++import           System.Random+import           Control.Monad.ST+import           Data.STRef+import           Data.Array.ST++shuffle :: STRef s StdGen -> [a] -> ST s [a]+shuffle ref xs = do+  arr <- mkArray xs+  bounds@(_, n) <- getBounds arr+  forM (range bounds) $ \ i -> do+    j <- randomIndex (i, n)+    vi <- readArray arr i+    vj <- readArray arr j+    writeArray arr j vi+    return vj+  where+    randomIndex bounds = do+      (a, gen) <- randomR bounds <$> readSTRef ref+      writeSTRef ref gen+      return a++mkArray :: [a] -> ST s (STArray s Int a)+mkArray xs = newListArray (1, length xs) xs
test/Test/Hspec/Core/ConfigSpec.hs view
@@ -8,7 +8,7 @@  spec :: Spec spec = do-  describe "readConfigFiles" $ around_ (withEnvironment []) $ around_ inTempDirectory $ do+  describe "readConfigFiles" $ around_ inTempDirectory $ around_ (withEnvironment [("HOME", "/foo")]) $ do     it "reads .hspec" $ do       dir <- getCurrentDirectory       let name = dir </> ".hspec"
test/Test/Hspec/Core/Example/LocationSpec.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE CPP #-} {-# OPTIONS_GHC -fno-warn-incomplete-patterns #-} {-# OPTIONS_GHC -fno-warn-missing-fields #-}+{-# OPTIONS_GHC -fno-warn-overlapping-patterns #-} module Test.Hspec.Core.Example.LocationSpec (spec) where  import           Helper
test/Test/Hspec/Core/RunnerSpec.hs view
@@ -285,6 +285,14 @@           , ""           , "  To rerun use: --match \"/bar/\""           , ""+#if __GLASGOW_HASKELL__ == 800+          , "WARNING:"+          , "  Your version of GHC is affected by https://ghc.haskell.org/trac/ghc/ticket/13285."+          , "  Source locations may not work as expected."+          , ""+          , "  Please consider upgrading GHC!"+          , ""+#endif           , "Randomized with seed 23"           , ""           , "Finished in 0.0000 seconds"
+ test/Test/Hspec/Core/ShuffleSpec.hs view
@@ -0,0 +1,24 @@+module Test.Hspec.Core.ShuffleSpec (spec) where++import           Prelude ()+import           Helper++import qualified Test.Hspec.Core.Shuffle as H++import           Data.Array.ST+import           Control.Monad.ST+import           Data.STRef+import           System.Random++spec :: Spec+spec = do+  describe "shuffle" $ do+    it "shuffles a list" $ do+      runST $ do+        gen <- newSTRef (mkStdGen 2)+        H.shuffle gen [1, 2, 3 :: Int]+      `shouldBe` [3, 1, 2]++  describe "mkArray" $ do+    it "creates an STArray from a list" $ do+      runST (H.mkArray [1, 2, 3 :: Int] >>= getElems) `shouldBe` [1, 2, 3]
vendor/Control/Concurrent/Async.hs view
@@ -146,7 +146,7 @@ #if __GLASGOW_HASKELL__ < 710 import Data.Typeable #endif-#if MIN_VERSION_base(4,9,0)+#if MIN_VERSION_base(4,9,0) && !MIN_VERSION_base(4,13,0) import Data.Semigroup (Semigroup((<>))) #endif