@@ -24,7 +24,7 @@ import GenModule (a)
24
24
import IntegrationTesting
25
25
26
26
main :: IO ()
27
- main = hspec $ around_ printMemoryHook $ do
27
+ main = hspec $ around_ printStatsHook $ do
28
28
29
29
describe " rules_haskell_tests" $ afterAll_ (shutdownBazel " ." ) $ do
30
30
it " bazel test" $ do
@@ -184,38 +184,54 @@ buildAndTest path = describe path $ afterAll_ (shutdownBazel path) $ do
184
184
185
185
-- | Print memory information before and after each test
186
186
-- Only perform the hook if RHT_PRINT_MEMORY is "true".
187
- printMemoryHook :: IO () -> IO ()
188
- printMemoryHook action = do
187
+ printStatsHook :: IO () -> IO ()
188
+ printStatsHook action = do
189
189
rhtPrintMem <- lookupEnv " RHT_PRINT_MEMORY"
190
190
case rhtPrintMem of
191
191
Just " true" -> bracket_
192
- (printMemory " === BEFORE ===" )
193
- (printMemory " === AFTER ===" )
192
+ (printStats " === BEFORE ===" )
193
+ (printStats " === AFTER ===" )
194
194
action
195
195
_ -> action
196
196
197
197
topPath :: String
198
198
topPath = " /usr/bin/top"
199
199
200
- -- | Print information about the current memory state to debug intermittent failures
200
+ dfPath :: String
201
+ dfPath = " /bin/df"
202
+
203
+ -- | Print information about the computer state to debug intermittent failures
201
204
-- Related to https://github.com/tweag/rules_haskell/issues/2089
202
- printMemory :: String -> IO ()
203
- printMemory msg = do
205
+ printStats :: String -> IO ()
206
+ printStats msg = do
204
207
-- Do not attempt to run top, if it does not exist.
205
208
topExists <- doesFileExist topPath
209
+ dfExists <- doesFileExist dfPath
210
+ if topExists || dfExists then putStrLn msg else pure ()
206
211
if topExists
207
- then _doPrintMemory msg
212
+ then _printMemory
213
+ else pure ()
214
+ if dfExists
215
+ then _printDiskInfo
208
216
else pure ()
209
217
210
218
-- | Print information about the current memory state to debug intermittent failures
211
219
-- Related to https://github.com/tweag/rules_haskell/issues/2089
212
- _doPrintMemory :: String -> IO ()
213
- _doPrintMemory msg = do
214
- putStrLn msg
220
+ _printMemory :: IO ()
221
+ _printMemory = do
215
222
(exitCode, stdOut, stdErr) <- Process. readProcessWithExitCode topPath [" -l" , " 1" , " -s" , " 0" , " -o" , " mem" , " -n" , " 15" ] " "
216
223
case exitCode of
217
224
ExitSuccess -> putStrLn stdOut
218
- ExitFailure _ -> putStrLn (" === printMemory failed ===\n " ++ stdErr)
225
+ ExitFailure _ -> putStrLn (" === _printMemory failed ===\n " ++ stdErr)
226
+
227
+ -- | Print information about the disk drives to debug intermittent failures
228
+ -- Related to https://github.com/tweag/rules_haskell/issues/2089
229
+ _printDiskInfo :: IO ()
230
+ _printDiskInfo = do
231
+ (exitCode, stdOut, stdErr) <- Process. readProcessWithExitCode dfPath [" -H" ] " "
232
+ case exitCode of
233
+ ExitSuccess -> putStrLn stdOut
234
+ ExitFailure _ -> putStrLn (" === _printDiskInfo failed ===\n " ++ stdErr)
219
235
220
236
-- Generated dependencies for testing the ghcide support
221
237
_ghciIDE :: Int
0 commit comments