Commit a80c158c authored by Francesco Gazzetta's avatar Francesco Gazzetta
Browse files

Allow new-run to run tests and benchmarks too

This is especially useful for passing arguments to a single test suite

Closes #4684.
parent 60232377
...@@ -70,10 +70,10 @@ runCommand = Client.installCommand { ...@@ -70,10 +70,10 @@ runCommand = Client.installCommand {
commandDescription = Just $ \pname -> wrapText $ commandDescription = Just $ \pname -> wrapText $
"Runs the specified executable, first ensuring it is up to date.\n\n" "Runs the specified executable, first ensuring it is up to date.\n\n"
++ "Any executable in any package in the project can be specified. " ++ "Any executable/test/benchmark in any package in the project can be "
++ "A package can be specified if contains just one executable. " ++ "specified. A package can be specified if contains just one "
++ "The default is to use the package in the current directory if it " ++ "executable. The default is to use the package in the current "
++ "contains just one executable.\n\n" ++ "directory if it contains just one executable.\n\n"
++ "Extra arguments can be passed to the program, but use '--' to " ++ "Extra arguments can be passed to the program, but use '--' to "
++ "separate arguments for the program from arguments for " ++ pname ++ "separate arguments for the program from arguments for " ++ pname
...@@ -259,6 +259,8 @@ singleExeOrElse :: IO (UnitId, UnqualComponentName) -> TargetsMap -> IO (UnitId, ...@@ -259,6 +259,8 @@ singleExeOrElse :: IO (UnitId, UnqualComponentName) -> TargetsMap -> IO (UnitId,
singleExeOrElse action targetsMap = singleExeOrElse action targetsMap =
case Set.toList . distinctTargetComponents $ targetsMap case Set.toList . distinctTargetComponents $ targetsMap
of [(unitId, CExeName component)] -> return (unitId, component) of [(unitId, CExeName component)] -> return (unitId, component)
[(unitId, CTestName component)] -> return (unitId, component)
[(unitId, CBenchName component)] -> return (unitId, component)
_ -> action _ -> action
-- | Filter the 'ElaboratedInstallPlan' keeping only the -- | Filter the 'ElaboratedInstallPlan' keeping only the
...@@ -307,14 +309,14 @@ selectPackageTargets targetSelector targets ...@@ -307,14 +309,14 @@ selectPackageTargets targetSelector targets
| otherwise | otherwise
= Left (TargetProblemNoTargets targetSelector) = Left (TargetProblemNoTargets targetSelector)
where where
-- Targets that can be executed
targetsExecutableLike =
concatMap (\kind -> filterTargetsKind kind targets)
[ExeKind, TestKind, BenchKind]
(targetsExesBuildable, (targetsExesBuildable,
targetsExesBuildable') = selectBuildableTargets' targetsExesBuildable') = selectBuildableTargets' targetsExecutableLike
. filterTargetsKind ExeKind
$ targets
targetsExes = forgetTargetsDetail targetsExes = forgetTargetsDetail targetsExecutableLike
. filterTargetsKind ExeKind
$ targets
-- | For a 'TargetComponent' 'TargetSelector', check if the component can be -- | For a 'TargetComponent' 'TargetSelector', check if the component can be
...@@ -326,12 +328,15 @@ selectPackageTargets targetSelector targets ...@@ -326,12 +328,15 @@ selectPackageTargets targetSelector targets
selectComponentTarget :: SubComponentTarget selectComponentTarget :: SubComponentTarget
-> AvailableTarget k -> Either TargetProblem k -> AvailableTarget k -> Either TargetProblem k
selectComponentTarget subtarget@WholeComponent t selectComponentTarget subtarget@WholeComponent t
| CExeName _ <- availableTargetComponentName t = case availableTargetComponentName t
= either (Left . TargetProblemCommon) return $ of CExeName _ -> component
selectComponentTargetBasic subtarget t CTestName _ -> component
| otherwise CBenchName _ -> component
= Left (TargetProblemComponentNotExe (availableTargetPackageId t) _ -> Left (TargetProblemComponentNotExe pkgid cname)
(availableTargetComponentName t)) where pkgid = availableTargetPackageId t
cname = availableTargetComponentName t
component = either (Left . TargetProblemCommon) return $
selectComponentTargetBasic subtarget t
selectComponentTarget subtarget t selectComponentTarget subtarget t
= Left (TargetProblemIsSubComponent (availableTargetPackageId t) = Left (TargetProblemIsSubComponent (availableTargetPackageId t)
......
Supports Markdown
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