From 9cf6f6602431e9cc547bb97ed7e7ae192b34d4e6 Mon Sep 17 00:00:00 2001 From: Troels Henriksen Date: Thu, 19 Oct 2023 15:29:32 +0200 Subject: [PATCH] Improve tests. --- cabal-install/src/Distribution/Client/Main.hs | 5 +++-- cabal-testsuite/PackageTests/Path/All/cabal.out | 6 ++++++ cabal-testsuite/PackageTests/Path/All/cabal.test.hs | 9 +-------- cabal-testsuite/PackageTests/Path/Single/cabal.out | 2 ++ cabal-testsuite/PackageTests/Path/Single/cabal.test.hs | 6 +----- cabal-testsuite/src/Test/Cabal/Prelude.hs | 1 + 6 files changed, 14 insertions(+), 15 deletions(-) create mode 100644 cabal-testsuite/PackageTests/Path/All/cabal.out create mode 100644 cabal-testsuite/PackageTests/Path/Single/cabal.out diff --git a/cabal-install/src/Distribution/Client/Main.hs b/cabal-install/src/Distribution/Client/Main.hs index b91788ee90e..b5d0effbeb7 100644 --- a/cabal-install/src/Distribution/Client/Main.hs +++ b/cabal-install/src/Distribution/Client/Main.hs @@ -236,6 +236,7 @@ import Distribution.Simple.Utils , notice , topHandler , tryFindPackageDesc + , withOutputMarker ) import Distribution.Text ( display @@ -1350,7 +1351,7 @@ 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. @@ -1358,5 +1359,5 @@ pathAction pathflags extraArgs globalFlags = do -- 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 diff --git a/cabal-testsuite/PackageTests/Path/All/cabal.out b/cabal-testsuite/PackageTests/Path/All/cabal.out new file mode 100644 index 00000000000..55d8b94bc3a --- /dev/null +++ b/cabal-testsuite/PackageTests/Path/All/cabal.out @@ -0,0 +1,6 @@ +# cabal path +cache-dir: /cabal.dist/home/.cabal/packages +logs-dir: /cabal.dist/home/.cabal/logs +store-dir: /cabal.dist/home/.cabal/store +config-file: /cabal.dist/home/.cabal/config +installdir: /cabal.dist/home/.cabal/bin diff --git a/cabal-testsuite/PackageTests/Path/All/cabal.test.hs b/cabal-testsuite/PackageTests/Path/All/cabal.test.hs index c04f06c6443..b8157a83ee8 100644 --- a/cabal-testsuite/PackageTests/Path/All/cabal.test.hs +++ b/cabal-testsuite/PackageTests/Path/All/cabal.test.hs @@ -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" [] diff --git a/cabal-testsuite/PackageTests/Path/Single/cabal.out b/cabal-testsuite/PackageTests/Path/Single/cabal.out new file mode 100644 index 00000000000..1ae82037846 --- /dev/null +++ b/cabal-testsuite/PackageTests/Path/Single/cabal.out @@ -0,0 +1,2 @@ +# cabal path +/cabal.dist/home/.cabal/bin diff --git a/cabal-testsuite/PackageTests/Path/Single/cabal.test.hs b/cabal-testsuite/PackageTests/Path/Single/cabal.test.hs index 02f276764b1..8eac59024f3 100644 --- a/cabal-testsuite/PackageTests/Path/Single/cabal.test.hs +++ b/cabal-testsuite/PackageTests/Path/Single/cabal.test.hs @@ -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"] diff --git a/cabal-testsuite/src/Test/Cabal/Prelude.hs b/cabal-testsuite/src/Test/Cabal/Prelude.hs index e0e63ac18f6..48016765e91 100644 --- a/cabal-testsuite/src/Test/Cabal/Prelude.hs +++ b/cabal-testsuite/src/Test/Cabal/Prelude.hs @@ -295,6 +295,7 @@ cabalGArgs global_args cmd args input = do , "info" , "init" , "haddock-project" + , "path" ] = [ ]