hspec-meta 1.8.2 → 1.8.3
raw patch · 7 files changed
+22/−19 lines, 7 files
Files
- hspec-meta.cabal +1/−1
- src/Test/Hspec/Compat.hs +9/−1
- src/Test/Hspec/Core/Type.hs +1/−0
- src/Test/Hspec/FailureReport.hs +3/−2
- src/Test/Hspec/Options.hs +1/−0
- src/Test/Hspec/Runner.hs +7/−3
- src/Test/Hspec/Util.hs +0/−12
hspec-meta.cabal view
@@ -1,5 +1,5 @@ name: hspec-meta-version: 1.8.2+version: 1.8.3 license: MIT license-file: LICENSE copyright: (c) 2011-2014 Simon Hengel,
src/Test/Hspec/Compat.hs view
@@ -3,6 +3,7 @@ showType , showFullType , readMaybe+, lookupEnv , module Data.IORef #if !MIN_VERSION_base(4,6,0) , modifyIORef'@@ -12,6 +13,7 @@ import Data.Typeable (Typeable, typeOf, typeRepTyCon) import Text.Read import Data.IORef+import System.Environment #if MIN_VERSION_base(4,4,0) import Data.Typeable.Internal (tyConModule, tyConName)@@ -19,7 +21,6 @@ #if !MIN_VERSION_base(4,6,0) import qualified Text.ParserCombinators.ReadP as P-import Prelude #endif #if !MIN_VERSION_base(4,6,0)@@ -51,6 +52,13 @@ readMaybe s = case readEither s of Left _ -> Nothing Right a -> Just a++-- | Return the value of the environment variable @var@, or @Nothing@ if+-- there is no such value.+--+-- For POSIX users, this is equivalent to 'System.Posix.Env.getEnv'.+lookupEnv :: String -> IO (Maybe String)+lookupEnv k = lookup k `fmap` getEnvironment #endif showType :: Typeable a => a -> String
src/Test/Hspec/Core/Type.hs view
@@ -27,6 +27,7 @@ import Data.List (isPrefixOf) import Data.Maybe (fromMaybe) +import Test.Hspec.Compat import Test.Hspec.Util import Test.Hspec.Expectations import Test.HUnit.Lang (HUnitFailure(..))
src/Test/Hspec/FailureReport.hs view
@@ -6,7 +6,8 @@ import System.IO import System.SetEnv-import Test.Hspec.Util (Path, safeTry, readMaybe, getEnv)+import Test.Hspec.Compat+import Test.Hspec.Util (Path, safeTry) data FailureReport = FailureReport { failureReportSeed :: Integer@@ -27,7 +28,7 @@ readFailureReport :: IO (Maybe FailureReport) readFailureReport = do- mx <- getEnv "HSPEC_FAILURES"+ mx <- lookupEnv "HSPEC_FAILURES" case mx >>= readMaybe of Nothing -> do hPutStrLn stderr "WARNING: Could not read environment variable HSPEC_FAILURES; `--rerun' is ignored!"
src/Test/Hspec/Options.hs view
@@ -13,6 +13,7 @@ import System.Console.GetOpt import Test.Hspec.Formatters +import Test.Hspec.Compat import Test.Hspec.Util -- for Monad (Either e) when base < 4.3
src/Test/Hspec/Runner.hs view
@@ -23,7 +23,7 @@ import Data.Monoid import Data.Maybe import System.IO-import System.Environment+import System.Environment (getProgName, getArgs, withArgs) import System.Exit import qualified Control.Exception as E @@ -32,7 +32,8 @@ import System.Random (newStdGen) import Control.Monad.IO.Class (liftIO) -import Test.Hspec.Util+import Test.Hspec.Compat (lookupEnv)+import Test.Hspec.Util (Path, stdGenToInteger) import Test.Hspec.Core.Type import Test.Hspec.Config import Test.Hspec.Formatters@@ -139,7 +140,7 @@ doesUseColor :: Handle -> Config -> IO Bool doesUseColor h c = case configColorMode c of- ColorAuto -> hIsTerminalDevice h+ ColorAuto -> (&&) <$> hIsTerminalDevice h <*> (not <$> isDumb) ColorNever -> return False ColorAlways -> return True @@ -147,6 +148,9 @@ withHandle c action = case configHandle c of Left h -> action h Right path -> withFile path WriteMode action++isDumb :: IO Bool+isDumb = maybe False (== "dumb") <$> lookupEnv "TERM" -- | Summary of a test run. data Summary = Summary {
src/Test/Hspec/Util.hs view
@@ -5,8 +5,6 @@ , Path , filterPredicate , formatRequirement-, readMaybe-, getEnv , strip , stdGenToInteger , stdGenFromInteger@@ -14,11 +12,9 @@ import Data.Int (Int32) import Data.List-import Data.Maybe import Data.Char (isSpace) import Control.Applicative import qualified Control.Exception as E-import qualified System.Environment as Environment import System.Random (StdGen) -- | Create a more readable display of a quantity of something.@@ -76,14 +72,6 @@ join xs = case xs of [x] -> x ++ " " ys -> concatMap (++ ", ") ys---- NOTE: base-4.6.0.0 provides a function with that name and type. For--- compatibility with earlier versions, we define our own version here.-readMaybe :: Read a => String -> Maybe a-readMaybe = fmap fst . listToMaybe . reads--getEnv :: String -> IO (Maybe String)-getEnv key = either (const Nothing) Just <$> safeTry (Environment.getEnv key) -- ensure that lines are not longer then given `n`, insert line breaks at word -- boundaries