hspec / silently

Prevent or capture output to stdout or other handles in Haskell
Other
21 stars 5 forks source link

Question - Is there a way to "Uncapture" #5

Closed theGhostJW closed 2 years ago

theGhostJW commented 5 years ago

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
andreasabel commented 2 years ago

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