Skip to content

Commit

Permalink
Merge branch 'main' into mgalazyn/feature/read-files-into-any-fromjson
Browse files Browse the repository at this point in the history
  • Loading branch information
carbolymer authored Feb 13, 2024
2 parents effe9fb + 8a40189 commit 51e9925
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/Hedgehog/Extras/Test/Process.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import Data.Bool (Bool (..))
import Data.Either (Either (..))
import Data.Eq (Eq (..))
import Data.Function (($), (&), (.))
import Data.Functor (Functor (..))
import Data.Functor ((<$>))
import Data.Int (Int)
import Data.Maybe (Maybe (..))
import Data.Monoid (Last (..), mempty, (<>))
Expand Down Expand Up @@ -170,10 +170,7 @@ execFlex' execConfig pkgBin envBin arguments = GHC.withFrozenCallStack $ do
case exitResult of
IO.ExitFailure exitCode -> do
H.annotate $ L.unlines $
[ "Process exited with non-zero exit-code: " ++ show @Int exitCode
, "━━━━ command ━━━━"
, pkgBin <> " " <> L.unwords (fmap argQuote arguments)
]
[ "Process exited with non-zero exit-code: " ++ show @Int exitCode ]
++ (if L.null stdout then [] else ["━━━━ stdout ━━━━" , stdout])
++ (if L.null stderr then [] else ["━━━━ stderr ━━━━" , stderr])
H.failMessage GHC.callStack "Execute process failed"
Expand All @@ -191,9 +188,9 @@ execFlexAny'
-> m (ExitCode, String, String) -- ^ exit code, stdout, stderr
execFlexAny' execConfig pkgBin envBin arguments = GHC.withFrozenCallStack $ do
cp <- procFlex' execConfig pkgBin envBin arguments
H.annotate . ("Command: " <>) $ case IO.cmdspec cp of
H.annotate . ("━━━━ command ━━━━\n" <>) $ case IO.cmdspec cp of
IO.ShellCommand cmd -> cmd
IO.RawCommand cmd args -> cmd <> " " <> L.unwords args
IO.RawCommand cmd args -> cmd <> " " <> L.unwords (argQuote <$> args)
H.evalIO $ IO.readCreateProcessWithExitCode cp ""

-- | Execute a process, returning '()'.
Expand All @@ -218,10 +215,7 @@ exec execConfig bin arguments = GHC.withFrozenCallStack $ do
(exitResult, stdout, stderr) <- execAny execConfig bin arguments
case exitResult of
IO.ExitFailure exitCode -> H.failMessage GHC.callStack . L.unlines $
[ "Process exited with non-zero exit-code: " ++ show @Int exitCode
, "━━━━ command ━━━━"
, bin <> " " <> L.unwords (fmap argQuote arguments)
]
[ "Process exited with non-zero exit-code: " ++ show @Int exitCode ]
++ (if L.null stdout then [] else ["━━━━ stdout ━━━━" , stdout])
++ (if L.null stderr then [] else ["━━━━ stderr ━━━━" , stderr])
IO.ExitSuccess -> return stdout
Expand All @@ -238,7 +232,7 @@ execAny execConfig bin arguments = GHC.withFrozenCallStack $ do
{ IO.env = getLast $ execConfigEnv execConfig
, IO.cwd = getLast $ execConfigCwd execConfig
}
H.annotate . ("Command: " <>) $ bin <> " " <> L.unwords arguments
H.annotate . ( "━━━━ command ━━━━\n" <>) $ bin <> " " <> L.unwords (argQuote <$> arguments)
H.evalIO $ IO.readCreateProcessWithExitCode cp ""

-- | Wait for process to exit.
Expand Down

0 comments on commit 51e9925

Please sign in to comment.