Skip to content

Commit f8b612a

Browse files
pepeiborrajneira
andauthored
Disable check project in the ghcide test suite (#2397)
* configureCheckProject * disable checkProject in the ghcide test suite * Fix getOptions to honor LSP config overrides This is a bit ugly, but we already do it in defaultMain I also realized I don't really understand the HLS config options anymore. * redundant import * fix tests Co-authored-by: Javier Neira <[email protected]>
1 parent 745ef26 commit f8b612a

File tree

4 files changed

+29
-13
lines changed

4 files changed

+29
-13
lines changed

ghcide/ghcide.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,7 @@ executable ghcide-bench
442442
base,
443443
bytestring,
444444
containers,
445+
data-default,
445446
directory,
446447
extra,
447448
filepath,

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,14 @@ instance IsIdeGlobal GlobalIdeOptions
308308
getIdeOptions :: Action IdeOptions
309309
getIdeOptions = do
310310
GlobalIdeOptions x <- getIdeGlobalAction
311-
return x
311+
env <- lspEnv <$> getShakeExtras
312+
case env of
313+
Nothing -> return x
314+
Just env -> do
315+
config <- liftIO $ LSP.runLspT env HLS.getClientConfig
316+
return x{optCheckProject = pure $ checkProject config,
317+
optCheckParents = pure $ checkParents config
318+
}
312319

313320
getIdeOptionsIO :: ShakeExtras -> IO IdeOptions
314321
getIdeOptionsIO ide = do

ghcide/test/exe/Main.hs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import Development.IDE.Test (Cursor,
5353
getInterfaceFilesDir,
5454
waitForAction,
5555
getStoredKeys,
56-
waitForTypecheck, waitForGC)
56+
waitForTypecheck, waitForGC, configureCheckProject)
5757
import Development.IDE.Test.Runfiles
5858
import qualified Development.IDE.Types.Diagnostics as Diagnostics
5959
import Development.IDE.Types.Location
@@ -427,10 +427,7 @@ diagnosticTests = testGroup "diagnostics"
427427
liftIO $ writeFile (path </> "hie.yaml") cradle
428428
_ <- createDoc "ModuleD.hs" "haskell" contentD
429429
expectDiagnostics
430-
[ ( "ModuleA.hs"
431-
, [(DsError, (1, 7), "Cyclic module dependency between ModuleA, ModuleB")]
432-
)
433-
, ( "ModuleB.hs"
430+
[ ( "ModuleB.hs"
434431
, [(DsError, (1, 7), "Cyclic module dependency between ModuleA, ModuleB")]
435432
)
436433
]
@@ -1603,10 +1600,7 @@ extendImportTests = testGroup "extend import actions"
16031600
codeActionTitle CodeAction{_title=x} = x
16041601

16051602
template setUpModules moduleUnderTest range expectedTitles expectedContentB = do
1606-
sendNotification SWorkspaceDidChangeConfiguration
1607-
(DidChangeConfigurationParams $ toJSON
1608-
def{checkProject = overrideCheckProject})
1609-
1603+
configureCheckProject overrideCheckProject
16101604

16111605
mapM_ (\x -> createDoc (fst x) "haskell" (snd x)) setUpModules
16121606
docB <- createDoc (fst moduleUnderTest) "haskell" (snd moduleUnderTest)
@@ -1783,6 +1777,7 @@ suggestImportTests = testGroup "suggest import actions"
17831777
test = test' False
17841778
wantWait = test' True True
17851779
test' waitForCheckProject wanted imps def other newImp = testSessionWithExtraFiles "hover" (T.unpack def) $ \dir -> do
1780+
configureCheckProject waitForCheckProject
17861781
let before = T.unlines $ "module A where" : ["import " <> x | x <- imps] ++ def : other
17871782
after = T.unlines $ "module A where" : ["import " <> x | x <- imps] ++ [newImp] ++ def : other
17881783
cradle = "cradle: {direct: {arguments: [-hide-all-packages, -package, base, -package, text, -package-env, -, A, Bar, Foo, B]}}"
@@ -5325,6 +5320,7 @@ ifaceTHTest = testCase "iface-th-test" $ runWithExtraFiles "TH" $ \dir -> do
53255320

53265321
ifaceErrorTest :: TestTree
53275322
ifaceErrorTest = testCase "iface-error-test-1" $ runWithExtraFiles "recomp" $ \dir -> do
5323+
configureCheckProject True
53285324
let bPath = dir </> "B.hs"
53295325
pPath = dir </> "P.hs"
53305326

@@ -5689,6 +5685,8 @@ getReferences' (file, l, c) includeDeclaration = do
56895685

56905686
referenceTestSession :: String -> FilePath -> [FilePath] -> (FilePath -> Session ()) -> TestTree
56915687
referenceTestSession name thisDoc docs' f = testSessionWithExtraFiles "references" name $ \dir -> do
5688+
-- needed to build whole project indexing
5689+
configureCheckProject True
56925690
let docs = map (dir </>) $ delete thisDoc $ nubOrd docs'
56935691
-- Initial Index
56945692
docid <- openDoc thisDoc "haskell"
@@ -5819,7 +5817,9 @@ runInDir' dir startExeIn startSessionIn extraOptions s = do
58195817
-- Only sets HOME if it wasn't already set.
58205818
setEnv "HOME" "/homeless-shelter" False
58215819
conf <- getConfigFromEnv
5822-
runSessionWithConfig conf cmd lspTestCaps projDir s
5820+
runSessionWithConfig conf cmd lspTestCaps projDir $ do
5821+
configureCheckProject False
5822+
s
58235823

58245824
getConfigFromEnv :: IO SessionConfig
58255825
getConfigFromEnv = do

ghcide/test/src/Development/IDE/Test.hs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,16 @@ module Development.IDE.Test
2929
, getStoredKeys
3030
, waitForCustomMessage
3131
, waitForGC
32-
,getBuildKeysBuilt,getBuildKeysVisited,getBuildKeysChanged,getBuildEdgesCount) where
32+
,getBuildKeysBuilt,getBuildKeysVisited,getBuildKeysChanged,getBuildEdgesCount,configureCheckProject) where
3333

3434
import Control.Applicative.Combinators
3535
import Control.Lens hiding (List)
3636
import Control.Monad
3737
import Control.Monad.IO.Class
38+
import Data.Aeson (toJSON)
3839
import qualified Data.Aeson as A
3940
import Data.Bifunctor (second)
41+
import Data.Default
4042
import qualified Data.Map.Strict as Map
4143
import Data.Maybe (fromJust)
4244
import Data.Text (Text)
@@ -45,7 +47,7 @@ import Development.IDE.Plugin.Test (TestRequest (..),
4547
WaitForIdeRuleResult,
4648
ideResultSuccess)
4749
import Development.IDE.Test.Diagnostic
48-
import Ide.Plugin.Config (CheckParents)
50+
import Ide.Plugin.Config (CheckParents, checkProject)
4951
import Language.LSP.Test hiding (message)
5052
import qualified Language.LSP.Test as LspTest
5153
import Language.LSP.Types hiding
@@ -246,3 +248,9 @@ waitForGC = waitForCustomMessage "ghcide/GC" $ \v ->
246248
case A.fromJSON v of
247249
A.Success x -> Just x
248250
_ -> Nothing
251+
252+
configureCheckProject :: Bool -> Session ()
253+
configureCheckProject overrideCheckProject =
254+
sendNotification SWorkspaceDidChangeConfiguration
255+
(DidChangeConfigurationParams $ toJSON
256+
def{checkProject = overrideCheckProject})

0 commit comments

Comments
 (0)