Skip to content

Commit e9530c2

Browse files
committed
Update benchmark examples for GHC 9.14
1 parent abb8a0e commit e9530c2

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

bench/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ examples:
2121
# Medium-sized project without TH
2222
- name: cabal
2323
package: Cabal
24-
version: 3.10.2.1
24+
version: 3.16.1.0
2525
modules:
2626
- src/Distribution/Simple.hs
2727
- src/Distribution/Types/ComponentLocalBuildInfo.hs
2828
extra-args: [] # extra HLS command line args
2929
# Small-sized project with TH
3030
- name: lsp-types
3131
package: lsp-types
32-
version: 2.3.0.1
32+
version: 2.4.0.0
3333
modules:
3434
- src/Language/LSP/Protocol/Types/SemanticTokens.hs
3535
- generated/Language/LSP/Protocol/Internal/Types/NotebookDocumentChangeEvent.hs

ghcide-bench/src/Experiments.hs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ setup = do
718718
-- Need this in case there is a parent cabal.project somewhere
719719
writeFile
720720
(path </> "cabal.project")
721-
"packages: ."
721+
(cabalProjectForPackage ExamplePackage{..})
722722
writeFile
723723
(path </> "cabal.project.local")
724724
""
@@ -745,6 +745,11 @@ setup = do
745745
writeFile hieYamlPath simpleStackCradleContent
746746
return path
747747

748+
checkExampleModulesExist benchDir (example ?config)
749+
case (buildTool ?config, exampleDetails (example ?config)) of
750+
(Cabal, ExampleHackage{}) -> buildCabalExample benchDir
751+
_ -> return ()
752+
748753
whenJust (shakeProfiling ?config) $ createDirectoryIfMissing True
749754

750755
let cleanUp = case exampleDetails (example ?config) of
@@ -756,6 +761,31 @@ setup = do
756761

757762
return SetupResult{..}
758763

764+
checkExampleModulesExist :: FilePath -> Example -> IO ()
765+
checkExampleModulesExist benchDir Example{..} =
766+
forM_ exampleModules $ \target -> do
767+
let fullPath = benchDir </> target
768+
exists <- doesFileExist fullPath
769+
unless exists $
770+
fail $ "Benchmark example " <> show exampleName
771+
<> " is missing target file " <> show target
772+
<> " at " <> fullPath
773+
774+
buildCabalExample :: HasConfig => FilePath -> IO ()
775+
buildCabalExample path = do
776+
output $ "cabal build all -j in " <> path
777+
cmd_ (Cwd path) ("cabal" :: String) (["build", "all", "-j"] :: [String])
778+
779+
cabalProjectForPackage :: ExamplePackage -> String
780+
cabalProjectForPackage ExamplePackage{packageName = "lsp-types"} =
781+
unlines
782+
[ "packages: ."
783+
, "if impl(ghc >= 9.14)"
784+
, " allow-newer: boring:base"
785+
]
786+
cabalProjectForPackage _ =
787+
"packages: ."
788+
759789
setupDocumentContents :: Config -> Session [DocumentPositions]
760790
setupDocumentContents config =
761791
forM (exampleModules $ example config) $ \m -> do

0 commit comments

Comments
 (0)