Skip to content

Commit 4e3efde

Browse files
committed
cabal-validate: Hide config and tool versions unless --verbose
`print-config`, `print-tool-versions`, and `time-summary` are no longer explicit steps, and are instead run implicitly (closes haskell#10570). `time-summary` is redundant in its current form and is removed. It may be added back in the future with more detailed output (e.g., which steps were run, how long did they take individually). `print-config` and `print-tool-versions` are hidden unless `--verbose` is given.
1 parent c3a9dd7 commit 4e3efde

File tree

3 files changed

+32
-55
lines changed

3 files changed

+32
-55
lines changed

cabal-validate/src/Cli.hs

+1-6
Original file line numberDiff line numberDiff line change
@@ -179,19 +179,14 @@ resolveOpts opts = do
179179
then rawSteps opts
180180
else
181181
concat
182-
[
183-
[ PrintConfig
184-
, PrintToolVersions
185-
, Build
186-
]
182+
[ [Build]
187183
, optional (rawDoctest opts) Doctest
188184
, optional (rawRunLibTests opts) LibTests
189185
, optional (rawRunLibSuite opts) LibSuite
190186
, optional (rawRunLibSuite opts && not (null (rawExtraCompilers opts))) LibSuiteExtras
191187
, optional (rawRunCliTests opts && not (rawLibOnly opts)) CliTests
192188
, optional (rawRunCliSuite opts && not (rawLibOnly opts)) CliSuite
193189
, optionals (rawSolverBenchmarks opts) [SolverBenchmarksTests, SolverBenchmarksRun]
194-
, [TimeSummary]
195190
]
196191

197192
targets' =

cabal-validate/src/Main.hs

+30-42
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Main
77
, runStep
88
) where
99

10-
import Control.Monad (forM_)
10+
import Control.Monad (forM_, when)
1111
import qualified Data.Text as T
1212
import qualified Data.Text.IO as T
1313
import qualified Data.Text.Lazy as T (toStrict)
@@ -16,9 +16,7 @@ import Data.Version (makeVersion, showVersion)
1616
import System.FilePath ((</>))
1717
import System.Process.Typed (proc, readProcessStdout_)
1818

19-
import ANSI (SGR (Bold, BrightCyan, Reset), setSGR)
2019
import Cli (Compiler (..), HackageTests (..), Opts (..), parseOpts)
21-
import ClockUtil (diffAbsoluteTime, formatDiffTime, getAbsoluteTime)
2220
import OutputUtil (printHeader, withTiming)
2321
import ProcessUtil (timed, timedWithCwd)
2422
import Step (Step (..), displayStep)
@@ -27,6 +25,8 @@ import Step (Step (..), displayStep)
2725
main :: IO ()
2826
main = do
2927
opts <- parseOpts
28+
printConfig opts
29+
printToolVersions opts
3030
forM_ (steps opts) $ \step -> do
3131
runStep opts step
3232

@@ -36,8 +36,6 @@ runStep opts step = do
3636
let title = displayStep step
3737
printHeader title
3838
let action = case step of
39-
PrintConfig -> printConfig opts
40-
PrintToolVersions -> printToolVersions opts
4139
Build -> build opts
4240
Doctest -> doctest opts
4341
LibTests -> libTests opts
@@ -47,7 +45,6 @@ runStep opts step = do
4745
CliTests -> cliTests opts
4846
SolverBenchmarksTests -> solverBenchmarksTests opts
4947
SolverBenchmarksRun -> solverBenchmarksRun opts
50-
TimeSummary -> timeSummary opts
5148
withTiming (startTime opts) title action
5249
T.putStrLn ""
5350

@@ -139,35 +136,37 @@ timedCabalBin opts package component args = do
139136

140137
-- | Print the configuration for CI logs.
141138
printConfig :: Opts -> IO ()
142-
printConfig opts = do
143-
putStr $
144-
unlines
145-
[ "compiler: "
146-
<> compilerExecutable (compiler opts)
147-
, "cabal-install: "
148-
<> cabal opts
149-
, "jobs: "
150-
<> show (jobs opts)
151-
, "steps: "
152-
<> unwords (map displayStep (steps opts))
153-
, "Hackage tests: "
154-
<> show (hackageTests opts)
155-
, "verbose: "
156-
<> show (verbose opts)
157-
, "extra compilers: "
158-
<> unwords (extraCompilers opts)
159-
, "extra RTS options: "
160-
<> unwords (rtsArgs opts)
161-
]
139+
printConfig opts =
140+
when (verbose opts) $
141+
putStr $
142+
unlines
143+
[ "compiler: "
144+
<> compilerExecutable (compiler opts)
145+
, "cabal-install: "
146+
<> cabal opts
147+
, "jobs: "
148+
<> show (jobs opts)
149+
, "steps: "
150+
<> unwords (map displayStep (steps opts))
151+
, "Hackage tests: "
152+
<> show (hackageTests opts)
153+
, "verbose: "
154+
<> show (verbose opts)
155+
, "extra compilers: "
156+
<> unwords (extraCompilers opts)
157+
, "extra RTS options: "
158+
<> unwords (rtsArgs opts)
159+
]
162160

163161
-- | Print the versions of tools being used.
164162
printToolVersions :: Opts -> IO ()
165-
printToolVersions opts = do
166-
timed opts (compilerExecutable (compiler opts)) ["--version"]
167-
timed opts (cabal opts) ["--version"]
163+
printToolVersions opts =
164+
when (verbose opts) $ do
165+
timed opts (cabal opts) ["--version"]
166+
timed opts (compilerExecutable (compiler opts)) ["--version"]
168167

169-
forM_ (extraCompilers opts) $ \compiler' -> do
170-
timed opts compiler' ["--version"]
168+
forM_ (extraCompilers opts) $ \compiler' -> do
169+
timed opts compiler' ["--version"]
171170

172171
-- | Run the build step.
173172
build :: Opts -> IO ()
@@ -412,14 +411,3 @@ solverBenchmarksRun opts = do
412411
, "--packages=Chart-diagrams"
413412
, "--print-trials"
414413
]
415-
416-
-- | Print the total time taken so far.
417-
timeSummary :: Opts -> IO ()
418-
timeSummary opts = do
419-
endTime <- getAbsoluteTime
420-
let totalDuration = diffAbsoluteTime endTime (startTime opts)
421-
putStrLn $
422-
setSGR [Bold, BrightCyan]
423-
<> "!!! Validation completed in "
424-
<> formatDiffTime totalDuration
425-
<> setSGR [Reset]

cabal-validate/src/Step.hs

+1-7
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ import qualified Data.Map.Strict as Map
1111

1212
-- | A step to be run by @cabal-validate@.
1313
data Step
14-
= PrintConfig
15-
| PrintToolVersions
16-
| Build
14+
= Build
1715
| Doctest
1816
| LibTests
1917
| LibSuite
@@ -22,7 +20,6 @@ data Step
2220
| CliSuite
2321
| SolverBenchmarksTests
2422
| SolverBenchmarksRun
25-
| TimeSummary
2623
deriving (Eq, Enum, Bounded, Show)
2724

2825
-- | Get the display identifier for a given `Step`.
@@ -34,8 +31,6 @@ data Step
3431
displayStep :: Step -> String
3532
displayStep step =
3633
case step of
37-
PrintConfig -> "print-config"
38-
PrintToolVersions -> "print-tool-versions"
3934
Build -> "build"
4035
Doctest -> "doctest"
4136
LibTests -> "lib-tests"
@@ -45,7 +40,6 @@ displayStep step =
4540
CliSuite -> "cli-suite"
4641
SolverBenchmarksTests -> "solver-benchmarks-tests"
4742
SolverBenchmarksRun -> "solver-benchmarks-run"
48-
TimeSummary -> "time-summary"
4943

5044
-- | A map from step names to `Steps`.
5145
--

0 commit comments

Comments
 (0)