Commit b13bcbfe authored by Francesco Gazzetta's avatar Francesco Gazzetta

Make new-bench actually run the benchmarks

Based on new-test.
parent 76262fcb
......@@ -103,7 +103,7 @@ benchAction (configFlags, configExFlags, installFlags, haddockFlags)
targetSelectors
let elaboratedPlan' = pruneInstallPlanToTargets
TargetActionBuild
TargetActionBench
targets
elaboratedPlan
return (elaboratedPlan', targets)
......
......@@ -357,6 +357,7 @@ packageFileMonitorKeyValues elab =
elab {
elabBuildTargets = [],
elabTestTargets = [],
elabBenchTargets = [],
elabReplTarget = Nothing,
elabBuildHaddocks = False
}
......@@ -1161,6 +1162,10 @@ buildInplaceUnpackedPackage verbosity
annotateFailureNoLog TestsFailed $
setup testCommand testFlags testArgs
whenBench $
annotateFailureNoLog BenchFailed $
setup benchCommand benchFlags benchArgs
-- Repl phase
--
whenRepl $
......@@ -1199,14 +1204,19 @@ buildInplaceUnpackedPackage verbosity
whenRebuild action
| null (elabBuildTargets pkg)
-- NB: we have to build the test suite!
, null (elabTestTargets pkg) = return ()
-- NB: we have to build the test/bench suite!
, null (elabTestTargets pkg)
, null (elabBenchTargets pkg) = return ()
| otherwise = action
whenTest action
| null (elabTestTargets pkg) = return ()
| otherwise = action
whenBench action
| null (elabBenchTargets pkg) = return ()
| otherwise = action
whenRepl action
| isNothing (elabReplTarget pkg) = return ()
| otherwise = action
......@@ -1239,6 +1249,11 @@ buildInplaceUnpackedPackage verbosity
verbosity builddir
testArgs = setupHsTestArgs pkg
benchCommand = Cabal.benchmarkCommand
benchFlags _ = setupHsBenchFlags pkg pkgshared
verbosity builddir
benchArgs = setupHsBenchArgs pkg
replCommand = Cabal.replCommand defaultProgramDb
replFlags _ = setupHsReplFlags pkg pkgshared
verbosity builddir
......
......@@ -201,6 +201,7 @@ data BuildFailureReason = DependentFailed PackageId
| ReplFailed SomeException
| HaddocksFailed SomeException
| TestsFailed SomeException
| BenchFailed SomeException
| InstallFailed SomeException
deriving Show
......@@ -892,6 +892,7 @@ dieOnBuildFailures verbosity plan buildOutcomes
ReplFailed _ -> "repl failed for " ++ pkgstr
HaddocksFailed _ -> "Failed to build documentation for " ++ pkgstr
TestsFailed _ -> "Tests failed for " ++ pkgstr
BenchFailed _ -> "Benchmarks failed for " ++ pkgstr
InstallFailed _ -> "Failed to build " ++ pkgstr
DependentFailed depid
-> "Failed to build " ++ display (packageId pkg)
......@@ -975,6 +976,7 @@ dieOnBuildFailures verbosity plan buildOutcomes
ReplFailed e -> Just e
HaddocksFailed e -> Just e
TestsFailed e -> Just e
BenchFailed e -> Just e
InstallFailed e -> Just e
DependentFailed _ -> Nothing
......
......@@ -51,6 +51,8 @@ module Distribution.Client.ProjectPlanning (
setupHsReplArgs,
setupHsTestFlags,
setupHsTestArgs,
setupHsBenchFlags,
setupHsBenchArgs,
setupHsCopyFlags,
setupHsRegisterFlags,
setupHsHaddockFlags,
......@@ -1638,6 +1640,7 @@ elaborateInstallPlan verbosity platform compiler compilerprogdb pkgConfigDB
-- Check the comments of those functions for more details.
elabBuildTargets = []
elabTestTargets = []
elabBenchTargets = []
elabReplTarget = Nothing
elabBuildHaddocks = False
......@@ -2304,6 +2307,7 @@ pkgHasEphemeralBuildTargets :: ElaboratedConfiguredPackage -> Bool
pkgHasEphemeralBuildTargets elab =
isJust (elabReplTarget elab)
|| (not . null) (elabTestTargets elab)
|| (not . null) (elabBenchTargets elab)
|| (not . null) [ () | ComponentTarget _ subtarget <- elabBuildTargets elab
, subtarget /= WholeComponent ]
......@@ -2329,6 +2333,7 @@ elabBuildTargetWholeComponents elab =
data TargetAction = TargetActionBuild
| TargetActionRepl
| TargetActionTest
| TargetActionBench
| TargetActionHaddock
-- | Given a set of per-package\/per-component targets, take the subset of the
......@@ -2396,6 +2401,7 @@ setRootTargets targetAction perPkgTargetsMap =
(Nothing, _) -> elab
(Just tgts, TargetActionBuild) -> elab { elabBuildTargets = tgts }
(Just tgts, TargetActionTest) -> elab { elabTestTargets = tgts }
(Just tgts, TargetActionBench) -> elab { elabBenchTargets = tgts }
(Just [tgt], TargetActionRepl) -> elab { elabReplTarget = Just tgt }
(Just _, TargetActionHaddock) -> elab { elabBuildHaddocks = True }
(Just _, TargetActionRepl) ->
......@@ -2426,6 +2432,7 @@ pruneInstallPlanPass1 pkgs =
find_root (InstallPlan.Configured (PrunedPackage elab _)) =
if not (null (elabBuildTargets elab)
&& null (elabTestTargets elab)
&& null (elabBenchTargets elab)
&& isNothing (elabReplTarget elab)
&& not (elabBuildHaddocks elab))
then Just (installedUnitId elab)
......@@ -2484,6 +2491,7 @@ pruneInstallPlanPass1 pkgs =
[ stanza
| ComponentTarget cname _ <- elabBuildTargets pkg
++ elabTestTargets pkg
++ elabBenchTargets pkg
++ maybeToList (elabReplTarget pkg)
, stanza <- maybeToList (componentOptionalStanza cname)
]
......@@ -3128,6 +3136,23 @@ setupHsTestArgs :: ElaboratedConfiguredPackage -> [String]
setupHsTestArgs elab =
mapMaybe (showTestComponentTarget (packageId elab)) (elabTestTargets elab)
setupHsBenchFlags :: ElaboratedConfiguredPackage
-> ElaboratedSharedConfig
-> Verbosity
-> FilePath
-> Cabal.BenchmarkFlags
setupHsBenchFlags _ _ verbosity builddir = Cabal.BenchmarkFlags
{ benchmarkDistPref = toFlag builddir
, benchmarkVerbosity = toFlag verbosity
, benchmarkOptions = mempty
}
setupHsBenchArgs :: ElaboratedConfiguredPackage -> [String]
setupHsBenchArgs elab =
mapMaybe (showBenchComponentTarget (packageId elab)) (elabBenchTargets elab)
setupHsReplFlags :: ElaboratedConfiguredPackage
-> ElaboratedSharedConfig
-> Verbosity
......
......@@ -42,6 +42,7 @@ module Distribution.Client.ProjectPlanning.Types (
ComponentTarget(..),
showComponentTarget,
showTestComponentTarget,
showBenchComponentTarget,
SubComponentTarget(..),
isTestComponentTarget,
......@@ -284,6 +285,7 @@ data ElaboratedConfiguredPackage
-- Build time related:
elabBuildTargets :: [ComponentTarget],
elabTestTargets :: [ComponentTarget],
elabBenchTargets :: [ComponentTarget],
elabReplTarget :: Maybe ComponentTarget,
elabBuildHaddocks :: Bool,
......@@ -659,6 +661,10 @@ isTestComponentTarget :: ComponentTarget -> Bool
isTestComponentTarget (ComponentTarget (CTestName _) _) = True
isTestComponentTarget _ = False
showBenchComponentTarget :: PackageId -> ComponentTarget -> Maybe String
showBenchComponentTarget _ (ComponentTarget (CBenchName n) _) = Just $ display n
showBenchComponentTarget _ _ = Nothing
---------------------------
-- Setup.hs script policy
--
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment