Skip to content
Permalink
Browse files

Wait in the test suite after draining output

This is an attempt to fix #385. Here's my best guess as to what's
happening:

* cat process runs
* Test process drains all output until cat's stdout closes
* cat is closing its stdout _before_ exiting (at least on some OSes)
* In some cases, test process calls stopProcess before cat actually
  exits

This change makes it so that we always wait for the process to exit
naturally first. NOTE: I've never reproed this issue myself, so I'm
unable to test if it fixes things.
  • Loading branch information...
snoyberg committed Mar 7, 2019
1 parent b003dfb commit 20fd6e2204e84ecf9c1ce99ed3778210a12545ff
Showing with 4 additions and 2 deletions.
  1. +4 −2 conduit-extra/test/Data/Conduit/Process/TypedSpec.hs
@@ -12,13 +12,15 @@ spec = do
let fp = "ChangeLog.md"
pc = setStdout createSource $ proc "cat" [fp]
bs <- B.readFile fp
bss <- withProcess_ pc $ \p -> runConduit $ getStdout p .| CL.consume
bss <- withProcess_ pc $ \p ->
runConduit (getStdout p .| CL.consume) <* waitExitCode p
B.concat bss `shouldBe` bs
it "cat works with withLoggedProcess_" $ do
let fp = "ChangeLog.md"
pc = proc "cat" [fp]
bs <- B.readFile fp
bss <- withLoggedProcess_ pc $ \p -> runConduit $ getStdout p .| CL.consume
bss <- withLoggedProcess_ pc $ \p ->
runConduit (getStdout p .| CL.consume) <* waitExitCode p
B.concat bss `shouldBe` bs
it "failing process throws" $ do
(withLoggedProcess_ (proc "cat" ["does not exist"]) $ \p -> do

0 comments on commit 20fd6e2

Please sign in to comment.
You can’t perform that action at this time.