@@ -11,6 +11,7 @@ import System.FilePath ((</>))
11
11
import System.Info (os )
12
12
import System.IO.Temp (withSystemTempDirectory )
13
13
import System.Environment (lookupEnv )
14
+ import System.Exit (ExitCode (.. ))
14
15
15
16
import qualified System.Process as Process
16
17
import Test.Hspec.Core.Spec (SpecM )
@@ -179,17 +180,22 @@ shutdownBazel = do
179
180
-- | Print memory information before and after each test
180
181
printMemoryHook :: IO () -> IO ()
181
182
printMemoryHook action = bracket_
182
- (printMemory " BEFORE" )
183
- (printMemory " AFTER" )
183
+ (printMemory " === BEFORE === " )
184
+ (printMemory " === AFTER === " )
184
185
action
185
186
186
187
-- | Print information about the current memory state to debug intermittent failures
187
188
-- Related to https://github.com/tweag/rules_haskell/issues/2089
188
189
printMemory :: String -> IO ()
189
190
printMemory msg = do
190
191
putStrLn msg
191
- (_, stdOut, _) <- Process. readProcessWithExitCode " /usr/bin/top" [" -l" , " 1" , " -s" , " 0" , " -o" , " mem" , " -n" , " 15" ] " "
192
- putStrLn stdOut
192
+ (exitCode, stdOut, stdErr) <- Process. readProcessWithExitCode " top" [" -l" , " 1" , " -s" , " 0" , " -o" , " mem" , " -n" , " 15" ] " "
193
+ -- (exitCode, stdOut, stdErr) <- Process.readProcessWithExitCode "/usr/bin/top" ["-l", "1", "-s", "0", "-o", "mem", "-n", "15"] ""
194
+ -- (exitCode, stdOut, stdErr) <- Process.readProcessWithExitCode "foo" ["-l", "1", "-s", "0", "-o", "mem", "-n", "15"] ""
195
+ -- putStrLn stdOut
196
+ case exitCode of
197
+ ExitSuccess -> putStrLn stdOut
198
+ ExitFailure _ -> putStrLn (" === printMemory failed ===\n " ++ stdErr)
193
199
194
200
-- Generated dependencies for testing the ghcide support
195
201
_ghciIDE :: Int
0 commit comments