Skip to content

Commit

Permalink
Fix #8400 by marking output of cabal list-bin
Browse files Browse the repository at this point in the history
The regular output of `cabal list-bin` should go to stdout always, but
be marked for the sake of the testsuite.
  • Loading branch information
andreasabel committed Jan 13, 2023
1 parent bcfc79c commit 6a60c65
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
13 changes: 10 additions & 3 deletions cabal-install/src/Distribution/Client/CmdListBin.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ import Distribution.Client.TargetProblem (TargetProblem (..))
import Distribution.Simple.BuildPaths (dllExtension, exeExtension)
import Distribution.Simple.Command (CommandUI (..))
import Distribution.Simple.Setup (configVerbosity, fromFlagOrDefault)
import Distribution.Simple.Utils (die', info, wrapText)
import Distribution.Simple.Utils (die', withOutputMarker, wrapText)
import Distribution.System (Platform)
import Distribution.Types.ComponentName (showComponentName)
import Distribution.Types.UnitId (UnitId)
import Distribution.Types.UnqualComponentName (UnqualComponentName)
import Distribution.Verbosity (normal, silent, verboseStderr)
import Distribution.Verbosity (silent, verboseStderr)
import System.FilePath ((<.>), (</>))

import qualified Data.Map as Map
Expand Down Expand Up @@ -133,7 +133,14 @@ listbinAction flags@NixStyleFlags{..} args globalFlags = do

case binfiles of
[] -> die' verbosity "No target found"
[exe] -> info normal exe
[exe] -> putStr $ withOutputMarker verbosity exe
-- Andreas, 2023-01-13, issue #8400:
-- Regular output of `list-bin` should go to stdout unconditionally,
-- but for the sake of the testsuite, we want to mark it so it goes
-- into the golden value for the test.
-- Note: 'withOutputMarker' only checks 'isVerboseMarkOutput',
-- thus, we can reuse @verbosity@ here, even if other components
-- of @verbosity@ may be wrong (like 'VStderr', verbosity level etc.).
_ -> die' verbosity "Multiple targets found"
where
defaultVerbosity = verboseStderr silent
Expand Down
1 change: 1 addition & 0 deletions cabal-testsuite/PackageTests/ListBin/Script/cabal.out
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- fake-package-0 (exe:cabal-script-script.hs) (first run)
<ROOT>/cabal.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/fake-package-0/x/cabal-script-script.hs/build/cabal-script-script.hs/cabal-script-script.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- SelectedComponent-1.0.0 (exe:testexe) (first run)
<ROOT>/cabal.dist/work/./dist/build/<ARCH>/ghc-<GHCVER>/SelectedComponent-1.0.0/build/testexe/testexe
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ import Test.Cabal.Prelude
main = cabalTest . void $ do
res <- cabal' "list-bin" ["exe:testexe"]

assertOutputContains "SelectedComponent-1.0.0" res
assertOutputContains "testexe" res
assertOutputContains "SelectedComponent-1.0.0/build/testexe/testexe" res

0 comments on commit 6a60c65

Please sign in to comment.