packages feed

process-streaming 0.7.0.0 → 0.7.0.1

raw patch · 5 files changed

+104/−7 lines, 5 files

Files

README.md view
@@ -17,3 +17,37 @@ Relevant thread in the Haskell Pipes Google Group:  https://groups.google.com/forum/#!searchin/haskell-pipes/pipes$20process/haskell-pipes/JFfyquj5HAg/Lxz7p50JOh4J++## Possible alternatives in Hackage++* turtle (pipes-based, shell programming)++http://hackage.haskell.org/package/turtle++* pipes-cliff (pipes-based)++http://hackage.haskell.org/package/pipes-cliff++* pipes-shell (pipes-based)++http://hackage.haskell.org/package/pipes-shell++* shelly (shell programming)++http://hackage.haskell.org/package/shelly++* shell-conduit (coundit-based, shell programming)++http://hackage.haskell.org/package/shell-conduit++* Data.Conduit.Process from conduit-extra (conduit-based)++http://hackage.haskell.org/package/conduit-extra++* System.IO.Streams.Process from io-streams (iostreams-based)++http://hackage.haskell.org/package/io-streams++* process-extras++http://hackage.haskell.org/package/process-extras
process-streaming.cabal view
@@ -1,5 +1,5 @@ name:          process-streaming-version:       0.7.0.0+version:       0.7.0.1 license:       BSD3 license-file:  LICENSE data-files:    
src/System/Process/Streaming.hs view
@@ -371,9 +371,9 @@ siphon' f = Siphon (Other (Exhaustive f))  {-| -    Useful in combination with 'Pipes.Text.toLazyM' from @pipes-text@ and-    'Pipes.ByteString.toLazyM' from @pipes-bytestring@, when the user-    wants to collect all the output. +    Useful in combination with folds from the pipes prelude or more+    specialized folds like 'Pipes.Text.toLazyM' from @pipes-text@ and+    'Pipes.ByteString.toLazyM' from @pipes-bytestring@.  -} fromFold :: (Producer b IO () -> IO a) -> Siphon b e a  fromFold aFold = siphon $ fmap (fmap pure) $ aFold 
src/System/Process/Streaming/Tutorial.hs view
@@ -100,10 +100,10 @@  We can do this with the 'toLazyM' fold from @pipes-bytestring@: ->>> execute (pipeo intoLazyBytes) (shell "echo ooo")+>>> execute (pipeo (fromFold B.toLazyM)) (shell "echo ooo") (ExitSuccess,"ooo\n") -But the 'intoLazyBytes' function is easier to use:+But the 'intoLazyBytes' 'Siphon' is easier to use:  >>> execute (pipeo intoLazyBytes) (shell "echo ooo") (ExitSuccess,"ooo\n")
tests/test.hs view
@@ -13,12 +13,14 @@ import Data.ByteString import Data.ByteString.Lazy as BL import Data.Text.Lazy as TL+import Data.Text.Lazy.Encoding as TL import Data.Typeable import Data.Tree import qualified Data.Attoparsec.Text as A import Control.Applicative import Control.Monad import Control.Monad.Trans.Except+import Control.Exception import Control.Lens (view) import Pipes import qualified Pipes.ByteString as B@@ -35,7 +37,7 @@ import System.IO.Error import System.Exit import System.Directory-import System.Process.Streaming+import System.Process.Streaming.Extended  main = defaultMain tests @@ -53,6 +55,9 @@             , testBranchingPipeline              , testDrainageDeadlock             , testAlternatingWithCombined +            , testDecodeFailure+            , testDecodeFailureX+            , testPiapIn              ]  -------------------------------------------------------------------------------@@ -319,4 +324,62 @@     lp = toLines T.decodeIso8859_1 (pure id)      countLines = fromFold $ P.sum . G.folds const () (const 1) . view T.lines +-------------------------------------------------------------------------------++testDecodeFailure :: TestTree+testDecodeFailure  = localOption (mkTimeout $ 20*(10^6)) $+    testCase "testDecodeFailure" $ do+        r <- decodeFailure+        case r of +            Left nonAscii -> return ()+            _ -> assertFailure "oops"++nonAscii :: BL.ByteString+nonAscii = TL.encodeUtf8 "\x4e2d"++decodeFailure :: IO (Either T.ByteString (ExitCode,((),TL.Text)))+decodeFailure = executeFallibly +    (pipeio (fromLazyBytes ("aaaaaaaa" <> nonAscii)) +            (encoded decodeAscii (unwanted id) intoLazyText)) +    (shell "cat")+++testDecodeFailureX :: TestTree+testDecodeFailureX  = localOption (mkTimeout $ 20*(10^6)) $+    testCase "testDecodeFailureX" $ do+        r <- tryLeftoverB decodeFailureX+        case r of +            Left (LeftoverException _ nonAscii) -> return ()+            _ -> assertFailure "oops"++tryLeftoverB :: IO a -> IO (Either (LeftoverException Data.ByteString.ByteString) a)+tryLeftoverB = Control.Exception.try++decodeFailureX :: IO (ExitCode,((),TL.Text))+decodeFailureX = execute+    (pipeio (fromLazyBytes ("aaaaaaaa" <> nonAscii)) +            (encoded decodeAscii _leftoverX intoLazyText)) +    (shell "cat")++-------------------------------------------------------------------------------++testPiapIn :: TestTree+testPiapIn = localOption (mkTimeout $ 5*(10^6)) $+    testCase "piapIn" $ do+        r <- piapIn+        case r of+            (ExitSuccess,"aaabbb") -> return ()+            _ -> assertFailure "oops"++piapIn :: IO (ExitCode, BL.ByteString)+piapIn = execute piping (shell "cat")+  where +    piping = toPiping $ +      piapi (fromLazyBytes "aaa")  +      *>+      piapi (fromLazyBytes "bbb")  +      *>+      piapo intoLazyBytes ++-------------------------------------------------------------------------------