@@ -13,12 +13,12 @@ import Test.Tasty
1313import Test.Tasty.ExpectedFailure (ignoreTestBecause )
1414import Test.Tasty.HUnit
1515import qualified Data.Text as T
16+ import System.Time.Extra (sleep )
1617
1718tests :: TestTree
1819tests = testGroup " completions" [
1920 testCase " works" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
2021 doc <- openDoc " Completion.hs" " haskell"
21- _ <- waitForDiagnosticsFrom doc
2222
2323 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " put"
2424 _ <- applyEdit doc te
@@ -35,7 +35,6 @@ tests = testGroup "completions" [
3535 , ignoreTestBecause " no support for itemCompletion/resolve requests"
3636 $ testCase " itemCompletion/resolve works" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
3737 doc <- openDoc " Completion.hs" " haskell"
38- _ <- waitForDiagnosticsFrom doc
3938
4039 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " put"
4140 _ <- applyEdit doc te
@@ -54,7 +53,8 @@ tests = testGroup "completions" [
5453
5554 , testCase " completes imports" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
5655 doc <- openDoc " Completion.hs" " haskell"
57- _ <- waitForDiagnosticsFrom doc
56+
57+ liftIO $ sleep 4
5858
5959 let te = TextEdit (Range (Position 1 17 ) (Position 1 26 )) " Data.M"
6060 _ <- applyEdit doc te
@@ -68,7 +68,8 @@ tests = testGroup "completions" [
6868
6969 , testCase " completes qualified imports" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
7070 doc <- openDoc " Completion.hs" " haskell"
71- _ <- waitForDiagnosticsFrom doc
71+
72+ liftIO $ sleep 4
7273
7374 let te = TextEdit (Range (Position 2 17 ) (Position 1 25 )) " Dat"
7475 _ <- applyEdit doc te
@@ -82,7 +83,8 @@ tests = testGroup "completions" [
8283
8384 , testCase " completes language extensions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
8485 doc <- openDoc " Completion.hs" " haskell"
85- _ <- waitForDiagnosticsFrom doc
86+
87+ liftIO $ sleep 4
8688
8789 let te = TextEdit (Range (Position 0 24 ) (Position 0 31 )) " "
8890 _ <- applyEdit doc te
@@ -95,7 +97,8 @@ tests = testGroup "completions" [
9597
9698 , testCase " completes pragmas" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
9799 doc <- openDoc " Completion.hs" " haskell"
98- _ <- waitForDiagnosticsFrom doc
100+
101+ liftIO $ sleep 4
99102
100103 let te = TextEdit (Range (Position 0 4 ) (Position 0 34 )) " "
101104 _ <- applyEdit doc te
@@ -110,7 +113,6 @@ tests = testGroup "completions" [
110113
111114 , testCase " completes pragmas no close" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
112115 doc <- openDoc " Completion.hs" " haskell"
113- _ <- waitForDiagnosticsFrom doc
114116
115117 let te = TextEdit (Range (Position 0 4 ) (Position 0 24 )) " "
116118 _ <- applyEdit doc te
@@ -125,7 +127,8 @@ tests = testGroup "completions" [
125127
126128 , testCase " completes options pragma" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
127129 doc <- openDoc " Completion.hs" " haskell"
128- _ <- waitForDiagnosticsFrom doc
130+
131+ liftIO $ sleep 4
129132
130133 let te = TextEdit (Range (Position 0 4 ) (Position 0 34 )) " OPTIONS"
131134 _ <- applyEdit doc te
@@ -141,8 +144,6 @@ tests = testGroup "completions" [
141144 , testCase " completes ghc options pragma values" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
142145 doc <- openDoc " Completion.hs" " haskell"
143146
144- _ <- waitForDiagnosticsFrom doc
145-
146147 let te = TextEdit (Range (Position 0 0 ) (Position 0 0 )) " {-# OPTIONS_GHC -Wno-red #-}\n "
147148 _ <- applyEdit doc te
148149
@@ -156,7 +157,7 @@ tests = testGroup "completions" [
156157
157158 , testCase " completes with no prefix" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
158159 doc <- openDoc " Completion.hs" " haskell"
159- _ <- waitForDiagnosticsFrom doc
160+
160161 compls <- getCompletions doc (Position 5 7 )
161162 liftIO $ any ((== " !!" ) . (^. label)) compls @? " "
162163
@@ -175,7 +176,7 @@ tests = testGroup "completions" [
175176
176177 , testCase " have implicit foralls on basic polymorphic types" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
177178 doc <- openDoc " Completion.hs" " haskell"
178- _ <- waitForDiagnosticsFrom doc
179+
179180 let te = TextEdit (Range (Position 5 7 ) (Position 5 9 )) " id"
180181 _ <- applyEdit doc te
181182 compls <- getCompletions doc (Position 5 9 )
@@ -185,7 +186,7 @@ tests = testGroup "completions" [
185186
186187 , testCase " have implicit foralls with multiple type variables" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
187188 doc <- openDoc " Completion.hs" " haskell"
188- _ <- waitForDiagnosticsFrom doc
189+
189190 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " flip"
190191 _ <- applyEdit doc te
191192 compls <- getCompletions doc (Position 5 11 )
@@ -201,7 +202,6 @@ snippetTests :: TestTree
201202snippetTests = testGroup " snippets" [
202203 testCase " work for argumentless constructors" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
203204 doc <- openDoc " Completion.hs" " haskell"
204- _ <- waitForDiagnosticsFrom doc
205205
206206 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " Nothing"
207207 _ <- applyEdit doc te
@@ -214,7 +214,6 @@ snippetTests = testGroup "snippets" [
214214
215215 , testCase " work for polymorphic types" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
216216 doc <- openDoc " Completion.hs" " haskell"
217- _ <- waitForDiagnosticsFrom doc
218217
219218 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " fold"
220219 _ <- applyEdit doc te
@@ -229,7 +228,6 @@ snippetTests = testGroup "snippets" [
229228
230229 , testCase " work for complex types" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
231230 doc <- openDoc " Completion.hs" " haskell"
232- _ <- waitForDiagnosticsFrom doc
233231
234232 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " mapM"
235233 _ <- applyEdit doc te
@@ -244,7 +242,6 @@ snippetTests = testGroup "snippets" [
244242
245243 , testCase " work for infix functions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
246244 doc <- openDoc " Completion.hs" " haskell"
247- _ <- waitForDiagnosticsFrom doc
248245
249246 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " even `filte"
250247 _ <- applyEdit doc te
@@ -259,7 +256,6 @@ snippetTests = testGroup "snippets" [
259256
260257 , testCase " work for infix functions in backticks" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
261258 doc <- openDoc " Completion.hs" " haskell"
262- _ <- waitForDiagnosticsFrom doc
263259
264260 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " even `filte`"
265261 _ <- applyEdit doc te
@@ -274,7 +270,6 @@ snippetTests = testGroup "snippets" [
274270
275271 , testCase " work for qualified infix functions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
276272 doc <- openDoc " Completion.hs" " haskell"
277- _ <- waitForDiagnosticsFrom doc
278273
279274 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " \"\" `Data.List.interspe"
280275 _ <- applyEdit doc te
@@ -289,7 +284,6 @@ snippetTests = testGroup "snippets" [
289284
290285 , testCase " work for qualified infix functions in backticks" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
291286 doc <- openDoc " Completion.hs" " haskell"
292- _ <- waitForDiagnosticsFrom doc
293287
294288 let te = TextEdit (Range (Position 5 7 ) (Position 5 24 )) " \"\" `Data.List.interspe`"
295289 _ <- applyEdit doc te
@@ -305,7 +299,6 @@ snippetTests = testGroup "snippets" [
305299 , ignoreTestBecause " ghcide does not support the completionSnippetsOn option" $
306300 testCase " respects lsp configuration" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
307301 doc <- openDoc " Completion.hs" " haskell"
308- _ <- waitForDiagnosticsFrom doc
309302
310303 let config = object [ " haskell" .= (object [" completionSnippetsOn" .= False ])]
311304
@@ -316,7 +309,6 @@ snippetTests = testGroup "snippets" [
316309
317310 , testCase " respects client capabilities" $ runSession hlsCommand noSnippetsCaps " test/testdata/completion" $ do
318311 doc <- openDoc " Completion.hs" " haskell"
319- _ <- waitForDiagnosticsFrom doc
320312
321313 checkNoSnippets doc
322314 ]
@@ -349,23 +341,23 @@ contextTests :: TestTree
349341contextTests = testGroup " contexts" [
350342 testCase " only provides type suggestions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
351343 doc <- openDoc " Context.hs" " haskell"
352- _ <- waitForDiagnosticsFrom doc
344+
353345 compls <- getCompletions doc (Position 2 17 )
354346 liftIO $ do
355347 compls `shouldContainCompl` " Integer"
356348 compls `shouldNotContainCompl` " interact"
357349
358350 , testCase " only provides value suggestions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
359351 doc <- openDoc " Context.hs" " haskell"
360- _ <- waitForDiagnosticsFrom doc
352+
361353 compls <- getCompletions doc (Position 3 9 )
362354 liftIO $ do
363355 compls `shouldContainCompl` " abs"
364356 compls `shouldNotContainCompl` " Applicative"
365357
366358 , testCase " completes qualified type suggestions" $ runSession hlsCommand fullCaps " test/testdata/completion" $ do
367359 doc <- openDoc " Context.hs" " haskell"
368- _ <- waitForDiagnosticsFrom doc
360+
369361 compls <- getCompletions doc (Position 2 26 )
370362 liftIO $ do
371363 compls `shouldNotContainCompl` " forkOn"
0 commit comments