Skip to content

Commit

Permalink
Re #6643 Introduce ActionNoFilteredBug
Browse files Browse the repository at this point in the history
  • Loading branch information
mpilgrem committed Sep 7, 2024
1 parent 543f517 commit 38bac14
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 21 deletions.
3 changes: 2 additions & 1 deletion doc/maintainers/stack_errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
In connection with considering Stack's support of the
[Haskell Error Index](https://errors.haskell.org/) initiative, this page seeks
to take stock of the errors that Stack itself can raise, by reference to the
`master` branch of the Stack repository. Last updated: 2024-08-02.
`master` branch of the Stack repository. Last updated: 2024-09-07.

* `Stack.main`: catches exceptions from action `commandLineHandler`.

Expand Down Expand Up @@ -385,6 +385,7 @@ to take stock of the errors that Stack itself can raise, by reference to the
[S-8100] | GHCProfOptionInvalid
[S-1727] | NotOnlyLocal [PackageName] [Text]
[S-6362] | CompilerVersionMismatch (Maybe (ActualCompiler, Arch)) (WantedCompiler, Arch) GHCVariant CompilerBuild VersionCheck WantedCompilerSetter Text
[S-4660] | ActionNotFilteredBug StyleDoc
~~~

- `Stack.Types.Compiler.CompilerException`
Expand Down
22 changes: 2 additions & 20 deletions src/Stack/Build/ExecutePackage.hs
Original file line number Diff line number Diff line change
Expand Up @@ -996,15 +996,7 @@ singleTest topts testsToRun ac ee task installedMap = do
announce "rerunning previously failed test"
pure True
TSUnknown -> pure True
else do
-- This should never be reached, because the action should have been
-- filtered out in Stack.Build.Execute.toActions. However, we leave
-- it as is, for now. The alternative would be to throw a Stack bug.
notifyIfNoRunTests <- view $ configL . to (.notifyIfNoRunTests)
when notifyIfNoRunTests $
announce "Test running disabled by --no-run-tests flag."
pure False

else prettyThrowM $ ActionNotFilteredBug "singleTest"
when toRun $ do
buildDir <- distDirFromDir pkgDir
hpcDir <- hpcDirFromDir pkgDir
Expand Down Expand Up @@ -1265,20 +1257,10 @@ singleBench beopts benchesToRun ac ee task installedMap = do
let args = map unqualCompToString benchesToRun <> maybe []
((:[]) . ("--benchmark-options=" <>))
beopts.additionalArgs

toRun <-
if beopts.runBenchmarks
then pure True
else do
-- This should never be reached, because the action should have been
-- filtered out in Stack.Build.Execute.toActions. However, we leave
-- it as is, for now. The alternative would be to throw a Stack bug.
notifyIfNoRunBenchmarks <-
view $ configL . to (.notifyIfNoRunBenchmarks)
when notifyIfNoRunBenchmarks $
announce "Benchmark running disabled by --no-run-benchmarks flag."
pure False

else prettyThrowM $ ActionNotFilteredBug "singleBench"
when toRun $ do
announce "benchmarks"
cabal CloseOnException KeepTHLoading ("bench" : args)
Expand Down
7 changes: 7 additions & 0 deletions src/Stack/Types/Build/Exception.hs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ data BuildPrettyException
VersionCheck
WantedCompilerSetter -- Way that the wanted compiler is set
StyleDoc -- recommended resolution
| ActionNotFilteredBug StyleDoc
deriving (Show, Typeable)

instance Pretty BuildPrettyException where
Expand Down Expand Up @@ -450,6 +451,12 @@ instance Pretty BuildPrettyException where
]
<> blankLine
<> resolution
pretty (ActionNotFilteredBug source) = bugPrettyReport "S-4660" $
fillSep
[ source
, flow "is seeking to run an action that should have been filtered from \
\the list of actions."
]

instance Exception BuildPrettyException

Expand Down

0 comments on commit 38bac14

Please sign in to comment.