From 6e738f738360b6ba1bc34bc40554cb8746974446 Mon Sep 17 00:00:00 2001 From: Pepe Iborra Date: Sat, 21 Aug 2021 19:35:52 +0200 Subject: [PATCH] Fix "after edit" experiments 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 --- ghcide/bench/lib/Experiments.hs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/ghcide/bench/lib/Experiments.hs b/ghcide/bench/lib/Experiments.hs index 59cbf7e104..4b3396d7db 100644 --- a/ghcide/bench/lib/Experiments.hs +++ b/ghcide/bench/lib/Experiments.hs @@ -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, @@ -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{..} -> @@ -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 -> @@ -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 ->