Skip to content

Commit

Permalink
remove usage of implicit-hie:gen-hie in bench,
Browse files Browse the repository at this point in the history
Due to its error behaviour on lsp-types-3.1.1.0,
In favor of using basic configuration for hie.yaml.
  • Loading branch information
soulomoon committed Mar 6, 2024
1 parent 24f86ed commit 1ff52c1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
1 change: 0 additions & 1 deletion ghcide-bench/ghcide-bench.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ test-suite test
default-language: GHC2021
build-tool-depends:
ghcide:ghcide,
implicit-hie:gen-hie
main-is: Main.hs
hs-source-dirs: test
ghc-options: -Wunused-packages
Expand Down
26 changes: 18 additions & 8 deletions ghcide-bench/src/Experiments.hs
Original file line number Diff line number Diff line change
Expand Up @@ -594,15 +594,25 @@ callCommandLogging cmd = do
output cmd
callCommand cmd

simpleCabalCradleContent :: String
simpleCabalCradleContent = "cradle:\n cabal:"

simpleStackCradleContent :: String
simpleStackCradleContent = "cradle:\n stack:"

-- | Setup the benchmark
-- we need to create a hie.yaml file for the examples
-- or the hie.yaml file would be searched in the parent directories recursively
-- implicit-hie is error prone for the example test `lsp-types-2.1.1.0`
-- we are using the simpleCabalCradleContent for the hie.yaml file instead.
-- it works if we have cabal > 3.2.
setup :: HasConfig => IO SetupResult
setup = do
-- when alreadyExists $ removeDirectoryRecursive examplesPath
benchDir <- case exampleDetails(example ?config) of
ExamplePath examplePath -> do
let hieYamlPath = examplePath </> "hie.yaml"
alreadyExists <- doesFileExist hieYamlPath
unless alreadyExists $
cmd_ (Cwd examplePath) (FileStdout hieYamlPath) ("gen-hie"::String)
unless alreadyExists $ writeFile hieYamlPath simpleCabalCradleContent
return examplePath
ExampleScript examplePath' scriptArgs -> do
let exampleDir = examplesPath </> exampleName (example ?config)
Expand All @@ -613,21 +623,22 @@ setup = do
cmd_ (Cwd exampleDir) examplePath scriptArgs
let hieYamlPath = exampleDir </> "hie.yaml"
alreadyExists <- doesFileExist hieYamlPath
unless alreadyExists $
cmd_ (Cwd exampleDir) (FileStdout hieYamlPath) ("gen-hie"::String)
unless alreadyExists $ writeFile hieYamlPath simpleCabalCradleContent

return exampleDir
ExampleHackage ExamplePackage{..} -> do
let path = examplesPath </> package
package = packageName <> "-" <> showVersion packageVersion
hieYamlPath = path </> "hie.yaml"
print hieYamlPath
alreadySetup <- doesDirectoryExist path
unless alreadySetup $
case buildTool ?config of
Cabal -> do
let cabalVerbosity = "-v" ++ show (fromEnum (verbose ?config))
callCommandLogging $ "cabal get " <> cabalVerbosity <> " " <> package <> " -d " <> examplesPath
let hieYamlPath = path </> "hie.yaml"
cmd_ (Cwd path) (FileStdout hieYamlPath) ("gen-hie"::String)
writeFile hieYamlPath simpleCabalCradleContent
-- Need this in case there is a parent cabal.project somewhere
writeFile
(path </> "cabal.project")
Expand Down Expand Up @@ -655,8 +666,7 @@ setup = do
,"compiler"]
]
)

cmd_ (Cwd path) (FileStdout hieYamlPath) ("gen-hie"::String) ["--stack"::String]
writeFile hieYamlPath simpleStackCradleContent
return path

whenJust (shakeProfiling ?config) $ createDirectoryIfMissing True
Expand Down
1 change: 0 additions & 1 deletion haskell-language-server.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -1842,7 +1842,6 @@ benchmark benchmark
build-tool-depends:
ghcide-bench:ghcide-bench,
hp2pretty:hp2pretty,
implicit-hie:gen-hie
default-extensions:
LambdaCase
RecordWildCards
Expand Down

0 comments on commit 1ff52c1

Please sign in to comment.