packages feed

silently 1.2.4.1 → 1.2.5

raw patch · 3 files changed

+32/−17 lines, 3 filesdep +temporarynew-uploaderPVP ok

version bump matches the API change (PVP)

Dependencies added: temporary

API changes (from Hackage documentation)

Files

silently.cabal view
@@ -1,24 +1,23 @@ name: silently-version: 1.2.4.1+version: 1.2.5 cabal-version: >= 1.8 build-type: Simple license: BSD3 license-file: LICENSE copyright: (c) Trystan Spangler 2011-maintainer: trystan.s@comcast.net-stability:-homepage: https://github.com/trystan/silently-package-url: https://github.com/trystan/silently-bug-reports: https://github.com/trystan/silently/issues+maintainer: Sönke Hahn <soenkehahn@gmail.com>, Simon Hengel <sol@typeful.net>+homepage: https://github.com/hspec/silently+package-url: https://github.com/hspec/silently+bug-reports: https://github.com/hspec/silently/issues synopsis: Prevent or capture writing to stdout and other handles. description: Prevent or capture writing to stdout and other handles.-category:+category: System, Testing author: Trystan Spangler tested-with: GHC ==7.0  source-repository head   type: git-  location: https://github.com/trystan/silently+  location: https://github.com/hspec/silently  Library   build-depends:@@ -48,7 +47,7 @@   type:       exitcode-stdio-1.0   ghc-options:-      -Wall -Werror -threaded+      -Wall -threaded   hs-source-dirs:       test   build-depends:@@ -56,6 +55,7 @@     , silently     , directory     , nanospec+    , temporary  -- This tests the generic implementation, that should work on all platforms. test-suite spec-generic@@ -65,8 +65,6 @@       exitcode-stdio-1.0   ghc-options:       -Wall -threaded-      -- FIXME: use -Werror-      -- -Wall -Werror -threaded   hs-source-dirs:       src     , test@@ -76,3 +74,4 @@     , deepseq     , directory     , nanospec+    , temporary
src/System/IO/Silently.hs view
@@ -64,7 +64,7 @@ getTempOrCurrentDirectory = getTemporaryDirectory `catchIOError` (\_ -> return ".")   where     -- NOTE: We can not use `catchIOError` from "System.IO.Error", it is only-    -- availabel in base >= 4.4.+    -- available in base >= 4.4.     catchIOError :: IO a -> (IOError -> IO a) -> IO a     catchIOError = E.catch @@ -104,8 +104,14 @@       go hs = goBracket go tmpHandle hs  goBracket :: ([Handle] -> IO a) -> Handle -> [Handle] -> IO a-goBracket go tmpHandle (h:hs) = E.bracket (do old <- hDuplicate h-                                              hDuplicateTo tmpHandle h-                                              return old)-                                        (\old -> hDuplicateTo old h >> hClose old)-                                        (\_   -> go hs)+goBracket go tmpHandle (h:hs) = do+  buffering <- hGetBuffering h+  let redirect = do+        old <- hDuplicate h+        hDuplicateTo tmpHandle h+        return old+      restore old = do+        hDuplicateTo old h+        hSetBuffering h buffering+        hClose old+  E.bracket redirect restore (\_ -> go hs)
test/Spec.hs view
@@ -4,8 +4,10 @@ import           System.IO import           System.IO.Silently import           System.Directory+import           System.IO.Temp  import           Control.Exception+import           Control.Monad  main :: IO () main = hspec spec@@ -26,3 +28,11 @@   describe "capture" $ do     it "captures stdout" $ do       capture (putStr "foo" >> return 23) `shouldReturn` ("foo", 23 :: Int)++  describe "hCapture" $ do+    forM_ [NoBuffering, LineBuffering, BlockBuffering Nothing] $ \buffering -> do+      it ("preserves " ++ show buffering) $ do+        withSystemTempFile "silently" $ \_file h -> do+          hSetBuffering h buffering+          _ <- hCapture [h] (return ())+          hGetBuffering h `shouldReturn` buffering