@@ -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+
759789setupDocumentContents :: Config -> Session [DocumentPositions ]
760790setupDocumentContents config =
761791 forM (exampleModules $ example config) $ \ m -> do
0 commit comments