Skip to content

Commit a4f0744

Browse files
committed
Check RHT_PRINT_MEMORY env variable on whether to run hook.
1 parent eb5a227 commit a4f0744

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

rules_haskell_tests/tests/RunTests.hs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,16 @@ buildAndTest path = describe path $ afterAll_ (shutdownBazel path) $ do
183183
-- * Print Memory Hooks
184184

185185
-- | Print memory information before and after each test
186+
-- Only perform the hook if RHT_PRINT_MEMORY is "true".
186187
printMemoryHook :: IO () -> IO ()
187-
printMemoryHook action = bracket_
188-
(printMemory "=== BEFORE ===")
189-
(printMemory "=== AFTER ===")
190-
action
188+
printMemoryHook action = do
189+
rhtPrintMem <- lookupEnv "RHT_PRINT_MEMORY"
190+
case rhtPrintMem of
191+
Just "true" -> bracket_
192+
(printMemory "=== BEFORE ===")
193+
(printMemory "=== AFTER ===")
194+
action
195+
_ -> action
191196

192197
-- | Print information about the current memory state to debug intermittent failures
193198
-- Related to https://github.com/tweag/rules_haskell/issues/2089

0 commit comments

Comments
 (0)