Skip to content

Commit

Permalink
Merge pull request #6642 from commercialhaskell/fix6641
Browse files Browse the repository at this point in the history
Fix #6641 `--dry-run` respects `--no-run-tests`, `--no-run-benchmarks`
  • Loading branch information
mpilgrem committed Aug 11, 2024
2 parents 40012d2 + f16cb5d commit a2f53e1
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 17 deletions.
5 changes: 4 additions & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ Bug fixes:

* Stack's in-app messages refer to https://haskellstack.org as currently
structured. (Most URLs in older Stack versions are redirected.)

* Stack's `upgrade` command only treats the current running Stack executable
as '`stack`' if the executable file is named `stack` or, on Windows,
`stack.exe`. Previously only how it was invoked was considered.
* `stack test --no-run-tests --dry-run` no longer reports that Stack would test
project packages with test suites and
`stack bench --no-run-benchmarks --dry-run` no longer reports that Stack
would benchmark project packages with benchmarks.

## v3.1.1 - 2024-07-28

Expand Down
56 changes: 40 additions & 16 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ import Stack.Types.Build
, taskProvides
)
import Stack.Types.Build.Exception ( BuildPrettyException (..) )
import Stack.Types.BuildOpts ( BuildOpts (..), TestOpts (..) )
import Stack.Types.BuildOpts
( BenchmarkOpts (..), BuildOpts (..), TestOpts (..) )
import Stack.Types.BuildOptsCLI ( BuildOptsCLI (..) )
import Stack.Types.BuildOptsMonoid ( ProgressBarFormat (..) )
import Stack.Types.Compiler ( ActualCompiler (..) )
Expand All @@ -84,7 +85,7 @@ import Stack.Types.NamedComponent
import Stack.Types.Package
( LocalPackage (..), Package (..), packageIdentifier )
import Stack.Types.Platform ( HasPlatform (..) )
import Stack.Types.Runner ( HasRunner, terminalL, viewExecutablePath )
import Stack.Types.Runner ( terminalL, viewExecutablePath )
import Stack.Types.SourceMap ( Target )
import qualified System.Directory as D
import qualified System.FilePath as FP
Expand All @@ -108,7 +109,7 @@ preFetch plan
TTRemotePackage _ _ pkgloc -> Set.singleton pkgloc

-- | Print a description of build plan for human consumption.
printPlan :: (HasRunner env, HasTerm env) => Plan -> RIO env ()
printPlan :: HasEnvConfig env => Plan -> RIO env ()
printPlan plan = do
case Map.elems plan.unregisterLocal of
[] -> prettyInfo $
Expand All @@ -135,24 +136,47 @@ printPlan plan = do
<> bulletedList (map displayTask xs)
<> line

buildOpts <- view buildOptsL
let hasTests = not . Set.null . testComponents . taskComponents
hasBenches = not . Set.null . benchComponents . taskComponents
tests = Map.elems $ Map.filter hasTests plan.finals
benches = Map.elems $ Map.filter hasBenches plan.finals
runTests = buildOpts.testOpts.runTests
runBenchmarks = buildOpts.benchmarkOpts.runBenchmarks

unless (null tests) $ do
prettyInfo $
flow "Would test:"
<> line
<> bulletedList (map displayTask tests)
<> line

unless (null benches) $ do
prettyInfo $
flow "Would benchmark:"
<> line
<> bulletedList (map displayTask benches)
<> line
unless (null tests) $
if runTests
then
prettyInfo $
flow "Would test:"
<> line
<> bulletedList (map displayTask tests)
<> line
else
prettyInfo $
fillSep
[ flow "Would not test, as running disabled by"
, style Shell "--no-run-tests"
, "flag."
]
<> line

unless (null benches) $
if runBenchmarks
then
prettyInfo $
flow "Would benchmark:"
<> line
<> bulletedList (map displayTask benches)
<> line
else
prettyInfo $
fillSep
[ flow "Would not benchmark, as running disabled by"
, style Shell "--no-run-benchmarks"
, "flag."
]
<> line

case Map.toList plan.installExes of
[] -> prettyInfo $
Expand Down

0 comments on commit a2f53e1

Please sign in to comment.