Hello community, here is the log from the commit of package ghc-hspec-core for openSUSE:Factory checked in at 2019-01-25 22:43:18 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/ghc-hspec-core (Old) and /work/SRC/openSUSE:Factory/.ghc-hspec-core.new.28833 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "ghc-hspec-core" Fri Jan 25 22:43:18 2019 rev:11 rq:667137 version:2.7.0 Changes: -------- --- /work/SRC/openSUSE:Factory/ghc-hspec-core/ghc-hspec-core.changes 2018-11-09 07:52:16.815858499 +0100 +++ /work/SRC/openSUSE:Factory/.ghc-hspec-core.new.28833/ghc-hspec-core.changes 2019-01-25 22:43:20.563229871 +0100 @@ -1,0 +2,12 @@ +Fri Jan 18 03:02:23 UTC 2019 - [email protected] + +- Update hspec-core to version 2.7.0. + Upstream does not provide a change log file. + +------------------------------------------------------------------- +Tue Jan 1 19:13:25 UTC 2019 - [email protected] + +- Update hspec-core to version 2.6.1. + Upstream does not provide a change log file. + +------------------------------------------------------------------- Old: ---- hspec-core-2.6.0.tar.gz New: ---- hspec-core-2.7.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ ghc-hspec-core.spec ++++++ --- /var/tmp/diff_new_pack.ojiFmR/_old 2019-01-25 22:43:21.523228688 +0100 +++ /var/tmp/diff_new_pack.ojiFmR/_new 2019-01-25 22:43:21.527228683 +0100 @@ -1,7 +1,7 @@ # # spec file for package ghc-hspec-core # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -19,7 +19,7 @@ %global pkg_name hspec-core %bcond_with tests Name: ghc-%{pkg_name} -Version: 2.6.0 +Version: 2.7.0 Release: 0 Summary: A Testing Framework for Haskell License: MIT ++++++ hspec-core-2.6.0.tar.gz -> hspec-core-2.7.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hspec-core-2.6.0/LICENSE new/hspec-core-2.7.0/LICENSE --- old/hspec-core-2.6.0/LICENSE 2018-11-04 02:37:12.000000000 +0100 +++ new/hspec-core-2.7.0/LICENSE 2019-01-17 15:23:45.000000000 +0100 @@ -1,4 +1,4 @@ -Copyright (c) 2011-2018 Simon Hengel <[email protected]> +Copyright (c) 2011-2019 Simon Hengel <[email protected]> Copyright (c) 2011-2012 Trystan Spangler <[email protected]> Copyright (c) 2011-2011 Greg Weber <[email protected]> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hspec-core-2.6.0/hspec-core.cabal new/hspec-core-2.7.0/hspec-core.cabal --- old/hspec-core-2.6.0/hspec-core.cabal 2018-11-04 02:37:12.000000000 +0100 +++ new/hspec-core-2.7.0/hspec-core.cabal 2019-01-17 15:23:45.000000000 +0100 @@ -4,13 +4,13 @@ -- -- see: https://github.com/sol/hpack -- --- hash: fef917dc0cb43c6da4719fb2d080d28e01d8bc888b679a3fa1c61559f02d9848 +-- hash: 39dc148675f73276544e876331589928821112ae13bb688991d3c5c5ee686cee name: hspec-core -version: 2.6.0 +version: 2.7.0 license: MIT license-file: LICENSE -copyright: (c) 2011-2018 Simon Hengel, +copyright: (c) 2011-2019 Simon Hengel, (c) 2011-2012 Trystan Spangler, (c) 2011 Greg Weber maintainer: Simon Hengel <[email protected]> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hspec-core-2.6.0/src/Test/Hspec/Core/Config/Options.hs new/hspec-core-2.7.0/src/Test/Hspec/Core/Config/Options.hs --- old/hspec-core-2.6.0/src/Test/Hspec/Core/Config/Options.hs 2018-11-04 02:37:12.000000000 +0100 +++ new/hspec-core-2.7.0/src/Test/Hspec/Core/Config/Options.hs 2019-01-17 15:23:45.000000000 +0100 @@ -33,6 +33,8 @@ data Config = Config { configIgnoreConfigFile :: Bool , configDryRun :: Bool +, configFocusedOnly :: Bool +, configFailOnFocused :: Bool , configPrintCpuTime :: Bool , configFastFail :: Bool , configFailureReport :: Maybe FilePath @@ -61,6 +63,8 @@ defaultConfig = Config { configIgnoreConfigFile = False , configDryRun = False +, configFocusedOnly = False +, configFailOnFocused = False , configPrintCpuTime = False , configFastFail = False , configFailureReport = Nothing @@ -190,10 +194,13 @@ ] runnerOptions :: Monad m => [OptDescr (Result m -> Result m)] -runnerOptions = [ - Option [] ["dry-run"] (NoArg setDryRun) "pretend that everything passed; don't verify anything" - , Option [] ["fail-fast"] (NoArg setFastFail) "abort on first failure" - , 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)" +runnerOptions = concat [ + mkFlag "dry-run" setDryRun "pretend that everything passed; don't verify anything" + , 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" + ] ++ [ + 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)" @@ -211,8 +218,18 @@ setMaxJobs :: Int -> Config -> Config setMaxJobs n c = c {configConcurrentJobs = Just n} - setDryRun = set $ \config -> config {configDryRun = True} - setFastFail = set $ \config -> config {configFastFail = True} + setDryRun :: Bool -> Config -> Config + setDryRun value config = config {configDryRun = value} + + setFocusedOnly :: Bool -> Config -> Config + setFocusedOnly value config = config {configFocusedOnly = value} + + setFailOnFocused :: Bool -> Config -> Config + setFailOnFocused value config = config {configFailOnFocused = value} + + setFastFail :: Bool -> Config -> Config + setFastFail value config = config {configFastFail = value} + setRerun = set $ \config -> config {configRerun = True} setRerunAllOnSuccess = set $ \config -> config {configRerunAllOnSuccess = True} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hspec-core-2.6.0/src/Test/Hspec/Core/Config.hs new/hspec-core-2.7.0/src/Test/Hspec/Core/Config.hs --- old/hspec-core-2.6.0/src/Test/Hspec/Core/Config.hs 2018-11-04 02:37:12.000000000 +0100 +++ new/hspec-core-2.7.0/src/Test/Hspec/Core/Config.hs 2019-01-17 15:23:45.000000000 +0100 @@ -3,9 +3,12 @@ Config (..) , ColorMode(..) , defaultConfig -, getConfig +, readConfig , configAddFilter , configQuickCheckArgs + +, readFailureReportOnRerun +, applyFailureReport #ifdef TEST , readConfigFiles #endif @@ -21,6 +24,7 @@ import System.Exit import System.FilePath import System.Directory +import System.Environment (getProgName) import qualified Test.QuickCheck as QC import Test.Hspec.Core.Util @@ -36,8 +40,8 @@ configFilterPredicate = Just p1 `filterOr` configFilterPredicate c } -mkConfig :: Maybe FailureReport -> Config -> Config -mkConfig mFailureReport opts = opts { +applyFailureReport :: Maybe FailureReport -> Config -> Config +applyFailureReport mFailureReport opts = opts { configFilterPredicate = matchFilter `filterOr` rerunFilter , configQuickCheckSeed = mSeed , configQuickCheckMaxSuccess = mMaxSuccess @@ -79,8 +83,31 @@ setSeed :: Integer -> QC.Args -> QC.Args setSeed n args = args {QC.replay = Just (mkGen (fromIntegral n), 0)} -getConfig :: Config -> String -> [String] -> IO (Maybe FailureReport, Config) -getConfig opts_ prog args = do +-- | +-- `readConfig` parses config options from several sources and constructs a +-- `Config` value. It takes options from: +-- +-- 1. @~/.hspec@ (a config file in the user's home directory) +-- 1. @.hspec@ (a config file in the current working directory) +-- 1. the environment variable @HSPEC_OPTIONS@ +-- 1. the provided list of command-line options (the second argument to @readConfig@) +-- +-- (precedence from low to high) +-- +-- When parsing fails then @readConfig@ writes an error message to `stderr` and +-- exits with `exitFailure`. +-- +-- When @--help@ is provided as a command-line option then @readConfig@ writes +-- a help message to `stdout` and exits with `exitSuccess`. +-- +-- A common way to use @readConfig@ is: +-- +-- @ +-- `System.Environment.getArgs` >>= readConfig `defaultConfig` +-- @ +readConfig :: Config -> [String] -> IO Config +readConfig opts_ args = do + prog <- getProgName configFiles <- do ignore <- ignoreConfigFile opts_ args case ignore of @@ -89,9 +116,12 @@ envVar <- fmap words <$> lookupEnv envVarName case parseOptions opts_ prog configFiles envVar args of Left (err, msg) -> exitWithMessage err msg - Right opts -> do - r <- if configRerun opts then readFailureReport opts else return Nothing - return (r, mkConfig r opts) + Right opts -> return opts + +readFailureReportOnRerun :: Config -> IO (Maybe FailureReport) +readFailureReportOnRerun config + | configRerun config = readFailureReport config + | otherwise = return Nothing readConfigFiles :: IO [ConfigFile] readConfigFiles = do diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hspec-core-2.6.0/src/Test/Hspec/Core/Runner.hs new/hspec-core-2.7.0/src/Test/Hspec/Core/Runner.hs --- old/hspec-core-2.6.0/src/Test/Hspec/Core/Runner.hs 2018-11-04 02:37:12.000000000 +0100 +++ new/hspec-core-2.7.0/src/Test/Hspec/Core/Runner.hs 2019-01-17 15:23:45.000000000 +0100 @@ -5,17 +5,26 @@ module Test.Hspec.Core.Runner ( -- * Running a spec hspec -, hspecWith -, hspecResult -, hspecWithResult +, runSpec --- * Types -, Summary (..) +-- * Config , Config (..) , ColorMode (..) , Path , defaultConfig , configAddFilter +, readConfig + +-- * Summary +, Summary (..) +, isSuccess +, evaluateSummary + +-- * Legacy +-- | The following primitives are deprecated. Use `runSpec` instead. +, hspecWith +, hspecResult +, hspecWithResult #ifdef TEST , rerunAll @@ -27,7 +36,7 @@ import Data.Maybe import System.IO -import System.Environment (getProgName, getArgs, withArgs) +import System.Environment (getArgs, withArgs) import System.Exit import qualified Control.Exception as E @@ -82,10 +91,18 @@ NodeWithCleanup _ xs -> NodeWithCleanup (\() -> return ()) (map removeCleanup xs) leaf@(Leaf _) -> leaf --- | Run given spec and write a report to `stdout`. +-- | Run a given spec and write a report to `stdout`. -- Exit with `exitFailure` if at least one spec item fails. +-- +-- /Note/: `hspec` handles command-line options and reads config files. This +-- is not always desired. Use `runSpec` if you need more control over these +-- aspects. hspec :: Spec -> IO () -hspec = hspecWith defaultConfig +hspec spec = + getArgs + >>= readConfig defaultConfig + >>= doNotLeakCommandLineArgumentsToExamples . runSpec spec + >>= evaluateSummary -- Add a seed to given config if there is none. That way the same seed is used -- for all properties. This helps with --seed and --rerun. @@ -99,20 +116,25 @@ -- | Run given spec with custom options. -- This is similar to `hspec`, but more flexible. hspecWith :: Config -> Spec -> IO () -hspecWith conf spec = do - r <- hspecWithResult conf spec - unless (isSuccess r) exitFailure +hspecWith config spec = getArgs >>= readConfig config >>= doNotLeakCommandLineArgumentsToExamples . runSpec spec >>= evaluateSummary +-- | `True` if the given `Summary` indicates that there were no +-- failures, `False` otherwise. isSuccess :: Summary -> Bool isSuccess summary = summaryFailures summary == 0 +-- | Exit with `exitFailure` if the given `Summary` indicates that there was at +-- least one failure. +evaluateSummary :: Summary -> IO () +evaluateSummary summary = unless (isSuccess summary) exitFailure + -- | Run given spec and returns a summary of the test run. -- -- /Note/: `hspecResult` does not exit with `exitFailure` on failing spec -- items. If you need this, you have to check the `Summary` yourself and act -- accordingly. hspecResult :: Spec -> IO Summary -hspecResult = hspecWithResult defaultConfig +hspecResult spec = getArgs >>= readConfig defaultConfig >>= doNotLeakCommandLineArgumentsToExamples . runSpec spec -- | Run given spec with custom options and returns a summary of the test run. -- @@ -120,11 +142,25 @@ -- items. If you need this, you have to check the `Summary` yourself and act -- accordingly. hspecWithResult :: Config -> Spec -> IO Summary -hspecWithResult config spec = do - prog <- getProgName - args <- getArgs - (oldFailureReport, c_) <- getConfig config prog args - c <- ensureSeed c_ +hspecWithResult config spec = getArgs >>= readConfig config >>= doNotLeakCommandLineArgumentsToExamples . runSpec spec + +-- | +-- `runSpec` is the most basic primitive to run a spec. `hspec` is defined in +-- terms of @runSpec@: +-- +-- @ +-- hspec spec = +-- `getArgs` +-- >>= `readConfig` `defaultConfig` +-- >>= `withArgs` [] . runSpec spec +-- >>= `evaluateSummary` +-- @ +runSpec :: Spec -> Config -> IO Summary +runSpec spec c_ = do + oldFailureReport <- readFailureReportOnRerun c_ + + c <- ensureSeed (applyFailureReport oldFailureReport c_) + if configRerunAllOnSuccess c -- With --rerun-all we may run the spec twice. For that reason GHC can not -- optimize away the spec tree. That means that the whole spec tree has to @@ -137,16 +173,39 @@ then rerunAllMode c oldFailureReport else normalMode c where - normalMode c = runSpec c spec + normalMode c = runSpec_ c spec rerunAllMode c oldFailureReport = do - summary <- runSpec c spec + summary <- runSpec_ c spec if rerunAll c oldFailureReport summary - then hspecWithResult config spec + then runSpec spec c_ else return summary -runSpec :: Config -> Spec -> IO Summary -runSpec config spec = do - doNotLeakCommandLineArgumentsToExamples $ withHandle config $ \h -> do +failFocused :: Item a -> Item a +failFocused item = item {itemExample = example} + where + failure = Failure Nothing (Reason "item is focused; failing due to --fail-on-focused") + example + | itemIsFocused item = \ params hook p -> do + Result info status <- itemExample item params hook p + return $ Result info $ case status of + Success -> failure + Pending _ _ -> failure + Failure{} -> status + | otherwise = itemExample item + +failFocusedItems :: Config -> Spec -> Spec +failFocusedItems config spec + | configFailOnFocused config = mapSpecItem_ failFocused spec + | otherwise = spec + +focusSpec :: Config -> Spec -> Spec +focusSpec config spec + | configFocusedOnly config = spec + | otherwise = focus spec + +runSpec_ :: Config -> Spec -> IO Summary +runSpec_ config spec = do + withHandle config $ \h -> do let formatter = fromMaybe specdoc (configFormatter config) seed = (fromJust . configQuickCheckSeed) config qcArgs = configQuickCheckArgs config @@ -157,9 +216,11 @@ useColor <- doesUseColor h config - let params = Params (configQuickCheckArgs config) (configSmallCheckDepth config) + let + focusedSpec = focusSpec config (failFocusedItems config spec) + params = Params (configQuickCheckArgs config) (configSmallCheckDepth config) - filteredSpec <- filterSpecs config . mapMaybe (toEvalTree params) . applyDryRun config <$> runSpecM (focus spec) + filteredSpec <- filterSpecs config . mapMaybe (toEvalTree params) . applyDryRun config <$> runSpecM focusedSpec (total, failures) <- withHiddenCursor useColor h $ do let diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hspec-core-2.6.0/src/Test/Hspec/Core/Util.hs new/hspec-core-2.7.0/src/Test/Hspec/Core/Util.hs --- old/hspec-core-2.6.0/src/Test/Hspec/Core/Util.hs 2018-11-04 02:37:12.000000000 +0100 +++ new/hspec-core-2.7.0/src/Test/Hspec/Core/Util.hs 2019-01-17 15:23:45.000000000 +0100 @@ -63,7 +63,7 @@ else s : go (y, ys) -- | --- A `Path` represents the location of an example within the spec tree. +-- A `Path` describes the location of a spec item within a spec tree. -- -- It consists of a list of group descriptions and a requirement description. type Path = ([String], String) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hspec-core-2.6.0/test/Helper.hs new/hspec-core-2.7.0/test/Helper.hs --- old/hspec-core-2.6.0/test/Helper.hs 2018-11-04 02:37:12.000000000 +0100 +++ new/hspec-core-2.7.0/test/Helper.hs 2019-01-17 15:23:45.000000000 +0100 @@ -1,5 +1,7 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE StandaloneDeriving #-} +{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE ConstraintKinds #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Helper ( module Test.Hspec.Meta @@ -96,7 +98,7 @@ timeout :: Seconds -> IO a -> IO (Maybe a) timeout = System.timeout . toMicroseconds -shouldUseArgs :: [String] -> (Args -> Bool) -> Expectation +shouldUseArgs :: HasCallStack => [String] -> (Args -> Bool) -> Expectation shouldUseArgs args p = do spy <- newIORef (H.paramsQuickCheckArgs defaultParams) let interceptArgs item = item {H.itemExample = \params action progressCallback -> writeIORef spy (H.paramsQuickCheckArgs params) >> H.itemExample item params action progressCallback} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hspec-core-2.6.0/test/Test/Hspec/Core/Config/OptionsSpec.hs new/hspec-core-2.7.0/test/Test/Hspec/Core/Config/OptionsSpec.hs --- old/hspec-core-2.6.0/test/Test/Hspec/Core/Config/OptionsSpec.hs 2018-11-04 02:37:12.000000000 +0100 +++ new/hspec-core-2.7.0/test/Test/Hspec/Core/Config/OptionsSpec.hs 2019-01-17 15:23:45.000000000 +0100 @@ -91,6 +91,7 @@ fromLeft (parseOptions [("~/.hspec", ["--fail"])] Nothing []) `shouldBe` (ExitFailure 1, unlines [ "my-spec: option `--fail' is ambiguous; could be one of:" + , " --fail-on-focused fail on focused spec items" , " --fail-fast abort on first failure" , " --failure-report=FILE read/write a failure report for use with --rerun" , "in config file ~/.hspec" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/hspec-core-2.6.0/test/Test/Hspec/Core/RunnerSpec.hs new/hspec-core-2.7.0/test/Test/Hspec/Core/RunnerSpec.hs --- old/hspec-core-2.6.0/test/Test/Hspec/Core/RunnerSpec.hs 2018-11-04 02:37:12.000000000 +0100 +++ new/hspec-core-2.7.0/test/Test/Hspec/Core/RunnerSpec.hs 2019-01-17 15:23:45.000000000 +0100 @@ -254,6 +254,43 @@ H.it "bar" True readIORef ref `shouldReturn` False + context "with --focused-only" $ do + let run = captureLines . withArgs ["--focused-only"] . H.hspec + context "when there aren't any focused spec items" $ do + it "does not run anything" $ do + r <- run $ do + H.it "foo" True + H.it "bar" True + normalizeSummary r `shouldBe` [ + "" + , "" + , "Finished in 0.0000 seconds" + , "0 examples, 0 failures" + ] + + context "with --fail-on-focused" $ do + let run = captureLines . ignoreExitCode . withArgs ["--fail-on-focused", "--seed", "23"] . H.hspec . removeLocations + it "fails on focused spec items" $ do + r <- run $ do + H.it "foo" True + H.fit "bar" True + normalizeSummary r `shouldBe` [ + "" + , "bar FAILED [1]" + , "" + , "Failures:" + , "" + , " 1) bar" + , " item is focused; failing due to --fail-on-focused" + , "" + , " To rerun use: --match \"/bar/\"" + , "" + , "Randomized with seed 23" + , "" + , "Finished in 0.0000 seconds" + , "1 example, 1 failure" + ] + context "with --fail-fast" $ do it "stops after first failure" $ do r <- captureLines . ignoreExitCode . withArgs ["--fail-fast", "--seed", "23"] . H.hspec . removeLocations $ do
