diff --git a/lib/BenchRunner.hs b/lib/BenchRunner.hs index 726bd71..9d8babf 100644 --- a/lib/BenchRunner.hs +++ b/lib/BenchRunner.hs @@ -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 diff --git a/lib/BuildLib.hs b/lib/BuildLib.hs index 67edc03..0b50061 100644 --- a/lib/BuildLib.hs +++ b/lib/BuildLib.hs @@ -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) @@ -262,15 +262,20 @@ 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 + res <- mapM action omponents return $ catMaybes res + + where + + actionBuildTarget :: String -> Maybe String + actionBuildTarget c = do + toStdoutV [str|#{buildProg} #{package}:#{componentPrefix}:#{c}|] + return (Just c) + + actionOnError :: String -> Maybe String + actionOnError c = do + print $ "Warning: Target does not exist" ++ ": " ++ c + return Nothing + + action c = + catch (actionBuildTarget c) (\(e :: ProcessFailure) -> actionOnError c) diff --git a/lib/TestRunner.hs b/lib/TestRunner.hs index 96883fe..477f1ee 100644 --- a/lib/TestRunner.hs +++ b/lib/TestRunner.hs @@ -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