Skip to content

Commit 23c8dcf

Browse files
committed
Minor refactor to checkProcessHasNotDied
To simplify the handling of maybe stderr.
1 parent 97c05b8 commit 23c8dcf

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

hydra-test-utils/src/Test/Hydra/Prelude.hs

+7-7
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,13 @@ checkProcessHasNotDied name processHandle mStdErr =
145145
waitForProcess processHandle >>= \case
146146
ExitSuccess -> failure "Process has stopped"
147147
ExitFailure exit -> do
148-
let failureMsg = "Process " <> show name <> " exited with failure code: " <> show exit
149-
errorMsg <- case mStdErr of
150-
Nothing -> pure [failureMsg]
151-
Just stdErr -> do
152-
errorOutput <- hGetContents stdErr
153-
pure [failureMsg, "Process stderr: " <> errorOutput]
154-
failure . toString $ unlines errorMsg
148+
mErrorOutput <- traverse hGetContents mStdErr
149+
let mErrorMsg = ("Process stderr: " <>) <$> mErrorOutput
150+
failure . toString $
151+
unlines
152+
( "Process " <> show name <> " exited with failure code: " <> show exit
153+
: maybeToList mErrorMsg
154+
)
155155

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

0 commit comments

Comments
 (0)