Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #6641 --dry-run respects --no-run-tests, --no-run-benchmarks #6642

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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