Closed erikryb closed 3 weeks ago
I have found a workaround, using a wrapper function:
bubblewrap :: IO () -> IO ()
bubblewrap io = do
try io :: IO (Either SomeException ())
hSetBuffering stdout NoBuffering
This wrapper function takes an IO action, and returns a new IO action that can be run by ghciwatch. It handles any exception (which is needed if the IO action performs an exit, which is the case for Tasty) and also sets the buffering back to NoBuffering after performing the IO action. We can now run Tasty tests in ghciwatch by adding the following comment in the source file:
-- $> bubblewrap (defaultMain =<< tests)
and running ghciwatch --enable-eval
.
Yeah, don't do that. The wrapper is a good solution. If stdout is line-buffered, then ghciwatch can't detect when GHCi writes a prompt (because the prompt is written without a trailing newline).
What happened?
Ghciwatch stops reloading after file changes if the command
hSetBuffering stdout LineBuffering
is ran in ghci. This affects running tests with Tasty.What did you expect to happen?
Ghciwatch should reload after file changes.
Steps to reproduce the issue
Create a project with one file:
Run
ghciwatch --enable-eval
. Edit the file and save. ghciwatch does not reload. If ghciwatch is aborted with CTRL-C, we get the following error:The version of ghciwatch with the bug
ghciwatch 1.0.1