hspec / silently

Prevent or capture output to stdout or other handles in Haskell

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question - Is there a way to "Uncapture"

theGhostJW opened this issue · comments

I am testing exception handling so running my test in IO and using capture grab the output so I can run assertions against the log.

     unit_go_home_iteration_fail = do
        (log, rslt) <- capture runExceptG2GoHomeCheckIO
         chkMessageInstances goHomeExceptionMessage 12 $ fromList . lines $ toStr log

Now silently is working as advertised and hijacking IO but unfortunately this means that I lose my test results in the console unless a test fails. So I get an output saying "All 34 tests passed" but only 12 individual test results are shown. The ones that run before the above test. So is there a way to uncapture so I can still get my results to console.....

    unit_go_home_iteration_fail = do
        (log, rslt) <- capture runExceptG2GoHomeCheckIO
         uncapture ???????????
         chkMessageInstances goHomeExceptionMessage 12 $ fromList . lines $ toStr log

Uncapture isn't possible in the simple capture model that this library implements.