Skip to content

Commit

Permalink
Minor refactor to checkProcessHasNotDied
Browse files Browse the repository at this point in the history
To simplify the handling of maybe stderr.
  • Loading branch information
ffakenz committed Jan 3, 2024
1 parent 97c05b8 commit 23c8dcf
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions hydra-test-utils/src/Test/Hydra/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,13 @@ checkProcessHasNotDied name processHandle mStdErr =
waitForProcess processHandle >>= \case
ExitSuccess -> failure "Process has stopped"
ExitFailure exit -> do
let failureMsg = "Process " <> show name <> " exited with failure code: " <> show exit
errorMsg <- case mStdErr of
Nothing -> pure [failureMsg]
Just stdErr -> do
errorOutput <- hGetContents stdErr
pure [failureMsg, "Process stderr: " <> errorOutput]
failure . toString $ unlines errorMsg
mErrorOutput <- traverse hGetContents mStdErr
let mErrorMsg = ("Process stderr: " <>) <$> mErrorOutput
failure . toString $
unlines
( "Process " <> show name <> " exited with failure code: " <> show exit
: maybeToList mErrorMsg
)

-- | Like 'coverTable', but construct the weight requirements generically from
-- the provided label.
Expand Down

0 comments on commit 23c8dcf

Please sign in to comment.