Skip to content

Commit 43a2598

Browse files
committed
exec*: shorten output (to enhance readibility)
1 parent 675a11d commit 43a2598

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

src/Hedgehog/Extras/Test/Process.hs

+7-15
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import Hedgehog (MonadTest)
4444
import Hedgehog.Extras.Internal.Cli (argQuote)
4545
import Hedgehog.Extras.Internal.Plan (Component (..), Plan (..))
4646
import Hedgehog.Extras.Stock.IO.Process (TimedOut (..))
47-
import Prelude (error)
47+
import Prelude (error, (++))
4848
import System.Exit (ExitCode)
4949
import System.FilePath (takeDirectory)
5050
import System.FilePath.Posix ((</>))
@@ -173,16 +173,12 @@ execFlex' execConfig pkgBin envBin arguments = GHC.withFrozenCallStack $ do
173173
case exitResult of
174174
IO.ExitFailure exitCode -> do
175175
H.annotate $ L.unlines $
176-
[ "Process exited with non-zero exit-code"
176+
[ "Process exited with non-zero exit-code: " ++ show @Int exitCode
177177
, "━━━━ command ━━━━"
178178
, pkgBin <> " " <> L.unwords (fmap argQuote arguments)
179-
, "━━━━ stdout ━━━━"
180-
, stdout
181-
, "━━━━ stderr ━━━━"
182-
, stderr
183-
, "━━━━ exit code ━━━━"
184-
, show @Int exitCode
185179
]
180+
++ if L.null stdout then [] else ["━━━━ stdout ━━━━" , stdout]
181+
++ if L.null stderr then [] else ["━━━━ stderr ━━━━" , stderr]
186182
H.failMessage GHC.callStack "Execute process failed"
187183
IO.ExitSuccess -> return stdout
188184

@@ -208,16 +204,12 @@ exec execConfig bin arguments = GHC.withFrozenCallStack $ do
208204
(exitResult, stdout, stderr) <- execAny execConfig bin arguments
209205
case exitResult of
210206
IO.ExitFailure exitCode -> H.failMessage GHC.callStack . L.unlines $
211-
[ "Process exited with non-zero exit-code"
207+
[ "Process exited with non-zero exit-code: " ++ show @Int exitCode
212208
, "━━━━ command ━━━━"
213209
, bin <> " " <> L.unwords (fmap argQuote arguments)
214-
, "━━━━ stdout ━━━━"
215-
, stdout
216-
, "━━━━ stderr ━━━━"
217-
, stderr
218-
, "━━━━ exit code ━━━━"
219-
, show @Int exitCode
220210
]
211+
++ if L.null stdout then [] else ["━━━━ stdout ━━━━" , stdout]
212+
++ if L.null stderr then [] else ["━━━━ stderr ━━━━" , stderr]
221213
IO.ExitSuccess -> return stdout
222214

223215
-- | Execute a process, returning the error code, the stdout, and the stderr.

0 commit comments

Comments
 (0)