From 2747a154ccc57c587e39d2885d2fb7c609504033 Mon Sep 17 00:00:00 2001 From: Fendor Date: Fri, 6 Oct 2023 11:49:03 +0200 Subject: [PATCH] Set the root for tests to the test directory On startup, HLS performs a sanity check to validate the GHC version for the project is the same as the GHC version used to build HLS. Due to some oversights, the tests always use HLS's cabal package to perform this check. This is (almost) valid for the tests but adds overhead for finding the GHC version for each integration test in HLS. Improves the startup time for each integration tests that depends on hls-test-utils. Thus, ghcide test suite is unaffected. Fix `findCradle` invocations to point to a file in the root directory. `findCradle` from hie-bios doesn't work correctly for directories and requires a file, even if that file doesn't exist. --- ghcide/session-loader/Development/IDE/Session.hs | 2 +- hls-test-utils/src/Test/Hls.hs | 1 + src/Ide/Main.hs | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ghcide/session-loader/Development/IDE/Session.hs b/ghcide/session-loader/Development/IDE/Session.hs index 46e41072cd..ab20945847 100644 --- a/ghcide/session-loader/Development/IDE/Session.hs +++ b/ghcide/session-loader/Development/IDE/Session.hs @@ -266,7 +266,7 @@ loadWithImplicitCradle mHieYaml rootDir = do getInitialGhcLibDirDefault :: Recorder (WithPriority Log) -> FilePath -> IO (Maybe LibDir) getInitialGhcLibDirDefault recorder rootDir = do - hieYaml <- findCradle def rootDir + hieYaml <- findCradle def (rootDir "a") cradle <- loadCradle def hieYaml rootDir libDirRes <- getRuntimeGhcLibDir (toCologActionWithPrio (cmapWithPrio LogHieBios recorder)) cradle case libDirRes of diff --git a/hls-test-utils/src/Test/Hls.hs b/hls-test-utils/src/Test/Hls.hs index 0bbdbc0b72..86fd4fcf6e 100644 --- a/hls-test-utils/src/Test/Hls.hs +++ b/hls-test-utils/src/Test/Hls.hs @@ -617,6 +617,7 @@ runSessionWithServer' plugins conf sconf caps root s = withLock lock $ keepCurr , argsDefaultHlsConfig = conf , argsLogger = argsLogger , argsIdeOptions = ideOptions + , argsProjectRoot = Just root } x <- runSessionWithHandles inW outR sconf' caps root s diff --git a/src/Ide/Main.hs b/src/Ide/Main.hs index b6ee489d7c..726eebc524 100644 --- a/src/Ide/Main.hs +++ b/src/Ide/Main.hs @@ -90,7 +90,7 @@ defaultMain recorder args idePlugins = do BiosMode PrintCradleType -> do dir <- IO.getCurrentDirectory - hieYaml <- Session.findCradle def dir + hieYaml <- Session.findCradle def (dir "a") cradle <- Session.loadCradle def hieYaml dir print cradle