Skip to content

Commit

Permalink
Fix "after edit" experiments
Browse files Browse the repository at this point in the history
When the example includes >1 modules, we have to wait for the progress
start of every edit. This is the sequence of events:

--> didChange A.hs
--> didChange B.hs
<-- ProgressStart (for A.hs change)
<-- ProgressDone (aborted)
<-- ProgressStart (for B.hs change)
<-- ProgressDone

The experiment needs to ignore the aborted progress done events and wait until the last progress done event.
To accomplish this, we wait for all the progress start events and then
wait for one progress done event
  • Loading branch information
pepeiborra committed Aug 22, 2021
1 parent 28222e9 commit 6e738f7
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions ghcide/bench/lib/Experiments.hs
Expand Up @@ -74,10 +74,10 @@ experiments =
isJust <$> getHover doc (fromJust identifierP),
---------------------------------------------------------------------------------------
bench "edit" $ \docs -> do
forM_ docs $ \DocumentPositions{..} ->
forM_ docs $ \DocumentPositions{..} -> do
changeDoc doc [charEdit stringLiteralP]
-- wait for a fresh build start
waitForProgressStart
-- wait for a fresh build start
waitForProgressStart
-- wait for the build to be finished
waitForProgressDone
return True,
Expand Down Expand Up @@ -121,8 +121,9 @@ experiments =
( \docs -> do
unless (any (isJust . identifierP) docs) $
error "None of the example modules is suitable for this experiment"
forM_ docs $ \DocumentPositions{..} ->
forM_ docs $ \DocumentPositions{..} -> do
forM_ identifierP $ \p -> changeDoc doc [charEdit p]
waitForProgressStart
waitForProgressDone
)
( \docs -> not . null . catMaybes <$> forM docs (\DocumentPositions{..} ->
Expand All @@ -139,8 +140,9 @@ experiments =
forM_ identifierP $ \p -> changeDoc doc [charEdit p]
)
( \docs -> do
forM_ docs $ \DocumentPositions{..} ->
forM_ docs $ \DocumentPositions{..} -> do
changeDoc doc [charEdit stringLiteralP]
waitForProgressStart
waitForProgressDone
not . null . catMaybes <$> forM docs (\DocumentPositions{..} -> do
forM identifierP $ \p ->
Expand All @@ -160,8 +162,9 @@ experiments =
liftIO $ appendFile (fromJust $ uriToFilePath hieYamlUri) "##\n"
sendNotification SWorkspaceDidChangeWatchedFiles $ DidChangeWatchedFilesParams $
List [ FileEvent hieYamlUri FcChanged ]
forM_ docs $ \DocumentPositions{..} ->
forM_ docs $ \DocumentPositions{..} -> do
changeDoc doc [charEdit stringLiteralP]
waitForProgressStart
waitForProgressDone
not . null . catMaybes <$> forM docs (\DocumentPositions{..} -> do
forM identifierP $ \p ->
Expand Down

0 comments on commit 6e738f7

Please sign in to comment.