Skip to content

Commit

Permalink
Solver Hackage benchmark: Explicitly initialize cabal config files
Browse files Browse the repository at this point in the history
hackage-benchmark uses the environment variable CABAL_CONFIG to specify the
location of the config file. cabal started requiring the config file to exist in
that case in 6942e7e, so this commit runs
"cabal user-config init".
  • Loading branch information
grayjay committed Jan 19, 2024
1 parent 9712115 commit 8d237c1
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions solver-benchmarks/HackageBenchmark.hs
Original file line number Diff line number Diff line change
Expand Up @@ -220,17 +220,12 @@ runCabal timeoutSeconds cabalUnderTest cabal flags = do
& Map.insert "CABAL_CONFIG" (cabalDir </> "config")
& Map.insert "CABAL_DIR" cabalDir

-- Run cabal update,
-- Initialize the config file, whether or not it already exists
runCabalCmdWithEnv cabalDir thisEnv ["user-config", "init", "--force"]

-- Run cabal update
putStrLn $ "Running cabal update (using " ++ cabal ++ ") ..."
(ec, uout, uerr) <- readCreateProcessWithExitCode (proc cabal ["update"])
{ cwd = Just cabalDir
, env = Just thisEnv
}
""
unless (ec == ExitSuccess) $ do
putStrLn uout
putStrLn uerr
exitWith ec
runCabalCmdWithEnv cabalDir thisEnv ["update"]

-- return an actual runner
return $ \pkg -> do
Expand Down Expand Up @@ -289,6 +284,17 @@ runCabal timeoutSeconds cabalUnderTest cabal flags = do
| fromString "There is no package named" `BS.isInfixOf` err = PkgNotFound
| otherwise = Unknown
return (CabalTrial time result)
where
runCabalCmdWithEnv cabalDir thisEnv args = do
(ec, uout, uerr) <- readCreateProcessWithExitCode (proc cabal args)
{ cwd = Just cabalDir
, env = Just thisEnv
}
""
unless (ec == ExitSuccess) $ do
putStrLn uout
putStrLn uerr
exitWith ec

isSampleLargeEnough :: PValue Double -> Int -> Bool
isSampleLargeEnough pvalue trials =
Expand Down

0 comments on commit 8d237c1

Please sign in to comment.