-
-
Notifications
You must be signed in to change notification settings - Fork 391
Synchronous progress reporting in tests #1770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4987a79
to
d30549e
Compare
-- 2. KickStarted - transitions from Idle into Reporting | ||
progressThread mostRecentProgressEvent inProgress = progressLoopIdle | ||
where | ||
progressLoopIdle = do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this does what you are describing, but it's really hard to see with the retries and the running of the reporter async with a kill. Is there a more direct encoding? Like when we get a progressUpdate Started
we sleep, then spawn the thread, and when we get Completed
we kill it? I spent a long time trying to find the loop, before realising the loop isn't even in progressLoop
, it's in lspShakeProgress
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused too. There's actually two loops, outer one in the mutually recursive functions forming the state machine, and inner one in lspShakeProgress
.
I think the code works fine and I don't see how to make it less confusing, so I've just added more comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was expecting the code to read something along the lines of:
state <- newVar Nothing
let progressUpdate KickCompleted =
join $ modifyVar state $ \case
Nothing -> pure (Nothing, pure ())
Just thread -> pure (Nothing, cancel thread)
progressUpdate KickStarted =
modifyVar_ state $ \case
Nothing -> Just <$> async (mRunLspT ...)
Just thread -> pure $ Just thread
So you don't need the outer loop. You'd also make progressStop be the same as KickCompleted, simplifying things further.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That code is pretty much equivalent to directProgressReporting
introduced in this PR for tests. And this is a good thing, because in hindsight it seems a terrible idea to have one implementation for testing and a different one for production. So the path is clear - adapt directProgressReporting
to be used for both and remove the old version.
Thank you both for the careful review. |
42c9bec
to
3f90536
Compare
3ae15d6
to
863695e
Compare
863695e
to
47bf559
Compare
This PR introduces a couple of new bugs:
Having one |
I'm pretty sure I fixed this in haskell/lsp@5fa33f8#diff-8e90cf08428164fe5d7ef53f4d8e7900169c97415b3198f3040e75b96803e009 |
My bad, it's not lsp-test fault - it was a division by zero bug in the |
Replaced by #1784 |
The WorkDoneBegin and WorkDoneEnd notifications are now sent synchronously for tests, to avoid timing issues reported in #1749