Skip to content
Snippets Groups Projects
Commit 51bf62cf authored by Francesco Gazzetta's avatar Francesco Gazzetta
Browse files

Better new-run error reporting

Report possible tests and benchmarks too when erroring because of
multiple available targets.
parent 9378f023
No related branches found
No related tags found
No related merge requests found
......@@ -29,7 +29,7 @@ import Distribution.Simple.Setup
import Distribution.Simple.Command
( CommandUI(..), usageAlternatives )
import Distribution.Types.ComponentName
( componentNameString )
( showComponentName )
import Distribution.Text
( display )
import Distribution.Verbosity
......@@ -400,12 +400,13 @@ renderTargetProblem (TargetProblemNoTargets targetSelector) =
renderTargetProblem (TargetProblemMatchesMultiple targetSelector targets) =
"The run command is for running a single executable at once. The target '"
++ showTargetSelector targetSelector ++ "' refers to "
++ renderTargetSelector targetSelector ++ " which includes the executables "
++ renderListCommaAnd
[ display name
| cname@CExeName{} <- map availableTargetComponentName targets
, let Just name = componentNameString cname
]
++ renderTargetSelector targetSelector ++ " which includes "
++ renderListCommaAnd ( ("the "++) <$>
showComponentName <$>
availableTargetComponentName <$>
foldMap
(\kind -> filterTargetsKind kind targets)
[ExeKind, TestKind, BenchKind] )
++ "."
renderTargetProblem (TargetProblemMultipleTargets selectorMap) =
......
......@@ -16,6 +16,6 @@ Building executable 'bar' for MultipleExes-1.0..
# cabal new-run
Up to date
# cabal new-run
cabal: The run command is for running a single executable at once. The target '' refers to the package MultipleExes-1.0 which includes the executables foo and bar.
cabal: The run command is for running a single executable at once. The target '' refers to the package MultipleExes-1.0 which includes the executable 'foo' and the executable 'bar'.
# cabal new-run
cabal: The run command is for running a single executable at once. The target 'MultipleExes' refers to the package MultipleExes-1.0 which includes the executables foo and bar.
cabal: The run command is for running a single executable at once. The target 'MultipleExes' refers to the package MultipleExes-1.0 which includes the executable 'foo' and the executable 'bar'.
......@@ -25,7 +25,7 @@ Building executable 'foo-exe' for bar-1.0..
# cabal new-run
cabal: No targets given and there is no package in the current directory. Use the target 'all' for all packages in the project or specify packages or components by name or location. See 'cabal build --help' for more details on target options.
# cabal new-run
cabal: The run command is for running a single executable at once. The target 'bar' refers to the package bar-1.0 which includes the executables foo-exe and bar-exe.
cabal: The run command is for running a single executable at once. The target 'bar' refers to the package bar-1.0 which includes the executable 'foo-exe' and the executable 'bar-exe'.
# cabal new-run
cabal: Ambiguous target 'foo-exe'. It could be:
bar:foo-exe (component)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment