hspec-core 2.2.0 → 2.2.1
raw patch · 4 files changed
+24/−8 lines, 4 files
Files
- hspec-core.cabal +1/−1
- src/Test/Hspec/Core/Formatters.hs +6/−3
- src/Test/Hspec/FailureReport.hs +15/−2
- test/Test/Hspec/Core/FormattersSpec.hs +2/−2
hspec-core.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: hspec-core-version: 2.2.0+version: 2.2.1 license: MIT license-file: LICENSE copyright: (c) 2011-2015 Simon Hengel,
src/Test/Hspec/Core/Formatters.hs view
@@ -191,10 +191,13 @@ writeLine (" " ++ x) where err = either (("uncaught exception: " ++) . formatException) id reason- formatLoc (Location file line _column accuracy) = " " ++ file ++ ":" ++ show line ++ ":" ++ bestEffortMarking+ formatLoc (Location file line _column accuracy) = " " ++ file ++ ":" ++ show line ++ ":" ++ message where- bestEffortMarking = case accuracy of- ExactLocation -> ""+ message = case accuracy of+ ExactLocation -> " " -- NOTE: Vim's default 'errorformat'+ -- requires a non-empty message. This is+ -- why we use a single space as message+ -- here. BestEffort -> " (best-effort)" defaultFooter :: FormatM ()
src/Test/Hspec/FailureReport.hs view
@@ -1,13 +1,17 @@+{-# LANGUAGE CPP #-} module Test.Hspec.FailureReport ( FailureReport (..) , writeFailureReport , readFailureReport ) where -import System.IO+#ifndef __GHCJS__ import System.SetEnv+import Test.Hspec.Core.Util (safeTry)+#endif+import System.IO import Test.Hspec.Compat-import Test.Hspec.Core.Util (Path, safeTry)+import Test.Hspec.Core.Util (Path) data FailureReport = FailureReport { failureReportSeed :: Integer@@ -18,6 +22,14 @@ } deriving (Eq, Show, Read) writeFailureReport :: FailureReport -> IO ()+#ifdef __GHCJS__+writeFailureReport _ = return ()+ -- ghcjs currently does not support setting environment variables+ -- (https://github.com/ghcjs/ghcjs/issues/263). Since writing a failure report+ -- into the environment is a non-essential feature we just disable this to be+ -- able to run hspec test-suites with ghcjs at all. Should be reverted once+ -- the issue is fixed.+#else writeFailureReport x = do -- on Windows this can throw an exception when the input is too large, hence -- we use `safeTry` here@@ -25,6 +37,7 @@ where onError err = do hPutStrLn stderr ("WARNING: Could not write environment variable HSPEC_FAILURES (" ++ show err ++ ")")+#endif readFailureReport :: IO (Maybe FailureReport) readFailureReport = do
test/Test/Hspec/Core/FormattersSpec.hs view
@@ -168,7 +168,7 @@ addLoc e = e {H.itemLocation = Just loc} r <- runSpec $ H.mapSpecItem_ addLoc $ do H.it "foo" False- r `shouldContain` [" test/FooSpec.hs:23:", " 1) foo"]+ r `shouldContain` [" test/FooSpec.hs:23: ", " 1) foo"] context "when source location is exact" $ do it "includes that source locations" $ do@@ -176,7 +176,7 @@ addLoc e = e {H.itemLocation = Just loc} r <- runSpec $ H.mapSpecItem_ addLoc $ do H.it "foo" False- r `shouldSatisfy` any (== " test/FooSpec.hs:23:")+ r `shouldSatisfy` any (== " test/FooSpec.hs:23: ") it "does not include 'best-effort' explanation" $ do let loc = H.Location "test/FooSpec.hs" 23 0 H.ExactLocation