Skip to content

Commit

Permalink
Improve tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Oct 19, 2023
1 parent 434cd98 commit 9cf6f66
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 15 deletions.
5 changes: 3 additions & 2 deletions cabal-install/src/Distribution/Client/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ import Distribution.Simple.Utils
, notice
, topHandler
, tryFindPackageDesc
, withOutputMarker
)
import Distribution.Text
( display
Expand Down Expand Up @@ -1350,13 +1351,13 @@ pathAction pathflags extraArgs globalFlags = do
getSomeDir PathConfigFile = getConfigFilePath (globalConfigFile globalFlags)
getSomeDir PathInstallDir =
fromFlagOrDefault defaultInstallPath (pure <$> cinstInstalldir (savedClientInstallFlags cfg))
printPath p = putStrLn . ((pathName p ++ ": ") ++) =<< getSomeDir p
printPath p = putStrLn . withOutputMarker verbosity . ((pathName p ++ ": ") ++) =<< getSomeDir p
-- If no paths have been requested, print all paths with labels.
--
-- If a single path has been requested, print that path without any label.
--
-- If multiple paths have been requested, print each of them with labels.
case fromFlag $ pathDirs pathflags of
[] -> mapM_ printPath [minBound .. maxBound]
[d] -> putStrLn =<< getSomeDir d
[d] -> putStrLn . withOutputMarker verbosity =<< getSomeDir d
ds -> mapM_ printPath ds
6 changes: 6 additions & 0 deletions cabal-testsuite/PackageTests/Path/All/cabal.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# cabal path
cache-dir: <ROOT>/cabal.dist/home/.cabal/packages
logs-dir: <ROOT>/cabal.dist/home/.cabal/logs
store-dir: <ROOT>/cabal.dist/home/.cabal/store
config-file: <ROOT>/cabal.dist/home/.cabal/config
installdir: <ROOT>/cabal.dist/home/.cabal/bin
9 changes: 1 addition & 8 deletions cabal-testsuite/PackageTests/Path/All/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
import Test.Cabal.Prelude

main = cabalTest . void $ do
res <- cabal_raw' ["path"] Nothing

assertOutputContains "config-file:" res
assertOutputContains "installdir:" res
assertOutputContains "cache-dir:" res
assertOutputContains "logs-dir:" res
assertOutputContains "store-dir:" res
main = cabalTest . void $ cabal "path" []
2 changes: 2 additions & 0 deletions cabal-testsuite/PackageTests/Path/Single/cabal.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal path
<ROOT>/cabal.dist/home/.cabal/bin
6 changes: 1 addition & 5 deletions cabal-testsuite/PackageTests/Path/Single/cabal.test.hs
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
import Test.Cabal.Prelude

main = cabalTest . void $ do
res <- cabal_raw' ["path", "--installdir"] Nothing

assertOutputDoesNotContain "installdir:" res
assertOutputContains "cabal/cabal-testsuite/PackageTests/Path/Single/cabal.dist/home/.cabal" res
main = cabalTest . void $ cabal "path" ["--installdir"]
1 change: 1 addition & 0 deletions cabal-testsuite/src/Test/Cabal/Prelude.hs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ cabalGArgs global_args cmd args input = do
, "info"
, "init"
, "haddock-project"
, "path"
]
= [ ]

Expand Down

0 comments on commit 9cf6f66

Please sign in to comment.