Fix: Show actual parse errors for external Fourmolu/Ormolu#4855
Fix: Show actual parse errors for external Fourmolu/Ormolu#4855ijatinydv wants to merge 7 commits intohaskell:masterfrom
Conversation
|
Do we perhaps want to add a regression test for this? |
I agree. Just pushed an update with tests for both of them. let me know if this looks good! |
|
@fendor almost 15 tests are failing. Can you help me in this where is the problem occuring? |
|
Your tests don't compile on older GHC versions, see |
|
@fendor right, I totally missed that. I tried to skip the lens dependency but totally forgot how overloaded the |
fendor
left a comment
There was a problem hiding this comment.
Some comments, Ill leave the rest to @georgefst
| assertBool ("Expected parse error details from stderr, got: " <> T.unpack msg) | ||
| ("parse error" `T.isInfixOf` msg) |
There was a problem hiding this comment.
Can we check for the actual message, or is parse error truly the only thing we get reliably check for?
There was a problem hiding this comment.
Can we check for the actual message, or is
parse errortruly the only thing we get reliably check for?
matching the full actual message gets pretty brittle since ghc changes its parser error formatting across versions (like injecting GHC codes or changing quote styles), and the <stdin> vs filepath prefix changes based on the environment.
since we're just verifying the stderr flow works, a stable substring is the safest choice to avoid flaky tests. i agree it could be more specific though, so i tightened it to "parse error on input" and dropped a comment in the code explaining the intentional flexibility. pushed the update, please have a review.
fendor
left a comment
There was a problem hiding this comment.
Very nice, LGTM!
Thank you for your contribution!
592f0f0 to
9cb9154
Compare
Right now, if you use an external
fourmoluorormoluexecutable and there's a syntax error in your file, the editor just pops up a genericInternal Error: Fourmolu failed with exit code 3. The actual parse error gets buried in the HLS logs, which is a bit frustrating since the bundled library paths already show the error directly in the IDE.This PR fixes that by grabbing the
stderroutput from the CLI process and tacking it onto thePluginInternalErrormessage for both plugins.A couple of minor UX details included:
T.nullguard so we don't append empty newlines if the formatter fails silently.T.stripEndinstead of stripping both sides so that the internal indentation of the GHC parse errors stays intact when it renders in the editor popup.Fixes #4853