Skip to content

Commit

Permalink
Set the root for tests to the test directory
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
fendor committed Oct 6, 2023
1 parent c941dac commit 2747a15
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ghcide/session-loader/Development/IDE/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions hls-test-utils/src/Test/Hls.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Ide/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 2747a15

Please sign in to comment.