Skip to content

Commit 81c46b6

Browse files
committed
clean up and revert other flakiness test changes
1 parent 42bbfbe commit 81c46b6

File tree

11 files changed

+149
-219
lines changed

11 files changed

+149
-219
lines changed

ghcide-test/exe/ResolveTests.hs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import Language.LSP.Test hiding (resolveCompletion)
2424
import Test.Hls (IdeState, SMethod (..), liftIO,
2525
mkPluginTestDescriptor,
2626
someMethodToMethodString,
27-
waitForKickDone)
27+
waitForAllProgressDone)
2828
import qualified Test.Hls.FileSystem as FS
2929
import Test.Tasty
3030
import Test.Tasty.HUnit
@@ -100,7 +100,7 @@ resolveRequests =
100100
, "data Foo = Foo { foo :: Int }"
101101
, "bar = Foo 4"
102102
]
103-
waitForKickDone
103+
waitForAllProgressDone
104104
items <- getCompletions doc (Position 2 7)
105105
let resolveCompItems = filter (\i -> "test item" `T.isPrefixOf` (i ^. J.label)) items
106106
liftIO $ assertEqual "There must be exactly two results" 2 (length resolveCompItems)
@@ -113,7 +113,7 @@ resolveRequests =
113113
, "data Foo = Foo { foo :: Int }"
114114
, "bar = Foo 4"
115115
]
116-
waitForKickDone
116+
waitForAllProgressDone
117117
-- Cant use 'getAllCodeActions', as this lsp-test function queries the diagnostic
118118
-- locations and we don't have diagnostics in these tests.
119119
cas <- Maybe.mapMaybe (preview _R) <$> getCodeActions doc (Range (Position 0 0) (Position 1 0))
@@ -128,7 +128,7 @@ resolveRequests =
128128
, "data Foo = Foo { foo :: Int }"
129129
, "bar = Foo 4"
130130
]
131-
waitForKickDone
131+
waitForAllProgressDone
132132
cd <- getCodeLenses doc
133133
let resolveCodeLenses = filter (\i -> case i ^. J.command of
134134
Just cmd -> "test item" `T.isPrefixOf` (cmd ^. J.title)

ghcide/session-loader/Development/IDE/Session.hs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
{-# LANGUAGE CPP #-}
2-
{-# LANGUAGE ImpredicativeTypes #-}
3-
{-# LANGUAGE TypeFamilies #-}
1+
{-# LANGUAGE CPP #-}
2+
{-# LANGUAGE TypeFamilies #-}
43

54
{-|
65
The logic for setting up a ghcide session by tapping into hie-bios.
@@ -119,7 +118,6 @@ import qualified System.Random as Random
119118
import System.Random (RandomGen)
120119
import Text.ParserCombinators.ReadP (readP_to_S)
121120

122-
import qualified Control.Monad.Catch as MC
123121
import GHC.Driver.Env (hsc_all_home_unit_ids)
124122
import GHC.Driver.Errors.Types
125123
import GHC.Types.Error (errMsgDiagnostic,
@@ -756,7 +754,6 @@ emptyHscEnv :: NameCache -> FilePath -> IO HscEnv
756754
emptyHscEnv nc libDir = do
757755
-- We call setSessionDynFlags so that the loader is initialised
758756
-- We need to do this before we call initUnits.
759-
-- we mask_ here because asynchronous exceptions might be swallowed
760757
env <- runGhc (Just libDir) $
761758
getSessionDynFlags >>= setSessionDynFlags >> getSession
762759
pure $ setNameCache nc (hscSetFlags ((hsc_dflags env){useUnicode = True }) env)

ghcide/src/Development/IDE/Core/ProgressReporting.hs

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,30 +23,24 @@ import Control.Concurrent.STM (STM)
2323
import Control.Concurrent.STM.Stats (TVar, atomically,
2424
atomicallyNamed, modifyTVar',
2525
newTVarIO, readTVar, retry)
26-
import Control.Concurrent.Strict (modifyVar_, newBarrier, newVar,
27-
signalBarrier, threadDelay)
26+
import Control.Concurrent.Strict (modifyVar_, newVar,
27+
threadDelay)
2828
import Control.Monad.Extra hiding (loop)
2929
import Control.Monad.IO.Class
3030
import Control.Monad.Trans.Class (lift)
31-
import qualified Data.Aeson as J
3231
import Data.Functor (($>))
3332
import qualified Data.Text as T
34-
import Data.Unique (hashUnique, newUnique)
3533
import Development.IDE.GHC.Orphans ()
3634
import Development.IDE.Types.Location
3735
import Development.IDE.Types.Options
3836
import qualified Focus
39-
import Language.LSP.Protocol.Message
4037
import Language.LSP.Protocol.Types
41-
import qualified Language.LSP.Protocol.Types as L
42-
import Language.LSP.Server (MonadLsp, ProgressAmount (..),
38+
import Language.LSP.Server (ProgressAmount (..),
4339
ProgressCancellable (..),
44-
sendNotification, sendRequest,
4540
withProgress)
4641
import qualified Language.LSP.Server as LSP
4742
import qualified StmContainers.Map as STM
4843
import UnliftIO (Async, async, bracket, cancel)
49-
import qualified UnliftIO.Exception as UE
5044

5145
data ProgressEvent
5246
= ProgressNewStarted
@@ -174,7 +168,7 @@ progressReportingNoTrace todo done (Just lspEnv) title optProgressStyle = do
174168
let _progressUpdate event = liftIO $ updateStateVar $ Event event
175169
_progressStop = updateStateVar StopProgress
176170
updateStateVar = modifyVar_ progressState . updateState (progressCounter lspEnv title optProgressStyle todo done)
177-
return ProgressReporting {_progressUpdate, _progressStop}
171+
return ProgressReporting {..}
178172

179173
-- | `progressReporting` initiates a new progress reporting session.
180174
-- It necessitates the active tracking of progress using the `inProgress` function.
@@ -202,28 +196,6 @@ progressReporting (Just lspEnv) title optProgressStyle = do
202196

203197
f = recordProgress inProgress file
204198

205-
withProgressDummy ::
206-
forall c m a.
207-
MonadLsp c m =>
208-
T.Text ->
209-
Maybe ProgressToken ->
210-
ProgressCancellable ->
211-
((ProgressAmount -> m ()) -> m a) ->
212-
m a
213-
withProgressDummy title _ _ f = do
214-
UE.bracket start end $ \_ ->
215-
f (const $ return ())
216-
where
217-
sendProgressReport token report = sendNotification SMethod_Progress $ ProgressParams token $ J.toJSON report
218-
start = UE.uninterruptibleMask_ $ do
219-
t <- L.ProgressToken . L.InR . T.pack . show . hashUnique <$> liftIO newUnique
220-
r <- liftIO newBarrier
221-
_ <- sendRequest SMethod_WindowWorkDoneProgressCreate (WorkDoneProgressCreateParams t) $ \_ -> liftIO $ signalBarrier r ()
222-
sendProgressReport t $ WorkDoneProgressBegin L.AString title Nothing Nothing Nothing
223-
return t
224-
end t = do
225-
sendProgressReport t (WorkDoneProgressEnd L.AString Nothing)
226-
227199
-- Kill this to complete the progress session
228200
progressCounter ::
229201
LSP.LanguageContextEnv c ->
@@ -233,12 +205,8 @@ progressCounter ::
233205
STM Int ->
234206
IO ()
235207
progressCounter lspEnv title optProgressStyle getTodo getDone =
236-
LSP.runLspT lspEnv $ withProgressChoice title Nothing NotCancellable $ \update -> loop update 0
208+
LSP.runLspT lspEnv $ withProgress title Nothing NotCancellable $ \update -> loop update 0
237209
where
238-
withProgressChoice = case optProgressStyle of
239-
TestReporting -> withProgressDummy
240-
_ -> withProgress
241-
242210
loop _ _ | optProgressStyle == NoProgress = forever $ liftIO $ threadDelay maxBound
243211
loop update prevPct = do
244212
(todo, done, nextPct) <- liftIO $ atomically $ do

ghcide/src/Development/IDE/Main.hs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,8 @@ import Development.IDE.Types.Location (NormalizedUri,
7777
toNormalizedFilePath')
7878
import Development.IDE.Types.Monitoring (Monitoring)
7979
import Development.IDE.Types.Options (IdeGhcSession,
80-
IdeOptions (..),
80+
IdeOptions (optCheckParents, optCheckProject, optReportProgress, optRunSubset),
8181
IdeTesting (IdeTesting),
82-
ProgressReportingStyle (TestReporting),
8382
clientSupportsProgress,
8483
defaultIdeOptions,
8584
optModifyDynFlags,
@@ -277,10 +276,7 @@ testing recorder projectRoot plugins =
277276
let
278277
defOptions = argsIdeOptions config sessionLoader
279278
in
280-
defOptions{
281-
optTesting = IdeTesting True
282-
, optProgressStyle = TestReporting
283-
}
279+
defOptions{ optTesting = IdeTesting True }
284280
lspOptions = argsLspOptions { LSP.optProgressStartDelay = 0, LSP.optProgressUpdateDelay = 0 }
285281
in
286282
arguments

ghcide/src/Development/IDE/Types/Options.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,6 @@ newtype IdeOTMemoryProfiling = IdeOTMemoryProfiling Bool
107107
data ProgressReportingStyle
108108
= Percentage -- ^ Report using the LSP @_percentage@ field
109109
| Explicit -- ^ Report using explicit 123/456 text
110-
| TestReporting -- ^ Special mode for testing, reports only start/stop
111110
| NoProgress -- ^ Do not report any percentage
112111
deriving Eq
113112

hls-test-utils/src/Test/Hls.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,6 @@ wrapClientLogger logger = do
758758
let lspLogRecorder = cmapWithPrio (renderStrict . layoutPretty defaultLayoutOptions. pretty) lspLogRecorder'
759759
return (lspLogRecorder <> logger, cb1)
760760

761-
762761
-- | Host a server, and run a test session on it.
763762
-- For setting custom timeout, set the environment variable 'LSP_TIMEOUT'
764763
-- * LSP_TIMEOUT=10 cabal test

plugins/hls-hlint-plugin/src/Ide/Plugin/Hlint.hs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ import System.Environment (setEnv,
6666
import Development.IDE.GHC.Compat (DynFlags,
6767
extensionFlags,
6868
ms_hspp_opts,
69-
topDir,
70-
uninterruptibleMaskM_)
69+
topDir)
7170
import qualified Development.IDE.GHC.Compat.Util as EnumSet
7271

7372
#if MIN_GHC_API_VERSION(9,4,0)
@@ -206,7 +205,7 @@ rules recorder plugin = do
206205

207206
defineNoFile (cmapWithPrio LogShake recorder) $ \GetHlintSettings -> do
208207
(Config flags) <- getHlintConfig plugin
209-
liftIO $ uninterruptibleMask_ $ argsSettings flags
208+
liftIO $ argsSettings flags
210209

211210
action $ do
212211
files <- Map.keys <$> getFilesOfInterestUntracked

plugins/hls-signature-help-plugin/src/Ide/Plugin/SignatureHelp.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ help when a space char is inserted, we probably have to use up-to-date results.
9494

9595
{-
9696
Here is a brief description of the algorithm of finding relevant bits from HIE AST
97-
1. let 'hsAppNode' = the smallest 'HsApp' AST node which contains the cursor postion
97+
1. let 'hsAppNode' = the smallest 'HsApp' AST node which contains the cursor position
9898
See 'extractInfoFromSmallestContainingFunctionApplicationAst'
9999
2. let 'functionNode' = the left-most node of 'hsAppNode'
100100
See 'getLeftMostNode'

scripts/eventlog-dump.fish

Lines changed: 0 additions & 122 deletions
This file was deleted.

0 commit comments

Comments
 (0)