Open chrissound opened 5 years ago
Thanks for the report!
I suspect I don't have much choice. The code to hook up Ghcid to Ghci with pipes etc. is at https://github.com/ndmitchell/ghcid/blob/master/src/Language/Haskell/Ghcid.hs#L63-L69. Is the result of CreatePipe
not seekable? If the test program leaves stdin in an inconsistent state, my guess is that it will severely upset Ghcid.
Adding verbose option(ghcid --test=Main.main Main.hs -v
) allows hDuplicate
to work properly(prints content of test.txt). However even with verbose enabled, about 20% of triggering fails with same message(*** Exception: <stdin>: hDuplicate: illegal operation (cannot flush the read buffer: underlying device is not seekable)
)
I'm using macOS 10.15.5, GHC 8.8.3/8.10.1
Surprised -v
makes it work better, but I still think the underlying issue will remain - I hijack the stdin, and that means a test that tries to use stdin is going to have a hard time.
Not sure if this is a bug or it's just the way ghcid works:
With
ghcid
While with
ghci
:The motivation for doing the above is essentially this question: https://stackoverflow.com/questions/50931355/how-can-i-test-a-program-reading-from-stdin-in-ghci/50932360
Complete repo here (just basically the file above): https://github.com/chrissound/GhciStdInTest