Skip to content

Commit

Permalink
Review commit
Browse files Browse the repository at this point in the history
  • Loading branch information
adithyaov committed Aug 12, 2022
1 parent 3db3372 commit edf4241
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
5 changes: 3 additions & 2 deletions lib/BenchRunner.hs
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,10 @@ runMeasurements targets = do
if commitCompare
then runBenchesComparing targets
else do
targets1 <- liftIO $ runBuild buildBench benchPackageName "bench" targets
buildableTargets <-
liftIO $ runBuild buildBench benchPackageName "bench" targets
-- XXX What is target_exe_extra_args here?
runBenchTargets benchPackageName "b" targets1
runBenchTargets benchPackageName "b" buildableTargets

runReports :: [String] -> Context ()
runReports benchmarks = do
Expand Down
32 changes: 17 additions & 15 deletions lib/BuildLib.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ module BuildLib
-- Imports
--------------------------------------------------------------------------------

import Control.Exception (SomeException, catch)
import Control.Monad (forM_, unless)
import Control.Exception (catch)
import Control.Monad (unless)
import Control.Monad.IO.Class (MonadIO(..))
import Control.Monad.Trans.Reader (ReaderT, asks)
import Data.List (nub, sort, intercalate, isSuffixOf)
Expand Down Expand Up @@ -261,16 +261,18 @@ getGhcVersion :: String -> IO String
getGhcVersion ghc = liftIO $ toLastLine [str|#{ghc} --numeric-version|]

runBuild :: String -> String -> String -> [String] -> IO [String]
runBuild buildProg package componentPrefix components = do
res <- mapM
(\c -> catch
( toStdoutV [str|#{buildProg} #{package}:#{componentPrefix}:#{c}|]
>> return (Just c)
)
(\e -> do
let err = show (e :: ProcessFailure)
print $ "Warning: Target does not exist"++ ": " ++ c
return Nothing
)
) components
return $ catMaybes res
runBuild buildProg package componentPrefix components =
catMaybes <$> mapM action omponents

where

actionBuildTarget c = do
toStdoutV [str|#{buildProg} #{package}:#{componentPrefix}:#{c}|]
return (Just c)

actionOnError c = do
print $ "Warning: Target does not exist:" ++ c
return Nothing

action c =
catch (actionBuildTarget c) (\(e :: ProcessFailure) -> actionOnError c)
5 changes: 3 additions & 2 deletions lib/TestRunner.hs
Original file line number Diff line number Diff line change
Expand Up @@ -261,13 +261,14 @@ runMeasurements :: [String] -> Context ()
runMeasurements targets = do
buildCmd <- getBuildCommand
benchPackageName <- asks bconfig_BENCHMARK_PACKAGE_NAME
targets1 <- liftIO $ runBuild buildCmd benchPackageName "test" targets
buildableTargets <-
liftIO $ runBuild buildCmd benchPackageName "test" targets

coverage <- asks bconfig_COVERAGE
when coverage $ do
buildDir <- asks bconfig_BUILD_DIR
liftIO $ toStdout [str|mkdir -p #{buildDir}/hpc|]
runBenchTargets benchPackageName "t" targets1
runBenchTargets benchPackageName "t" buildableTargets

-------------------------------------------------------------------------------
-- Build and run targets
Expand Down

0 comments on commit edf4241

Please sign in to comment.