Skip to content

Commit

Permalink
Merge pull request #9614 from haskell/test-help-prints-config-file
Browse files Browse the repository at this point in the history
Test that the last line `--help` is the name of the config file
  • Loading branch information
mergify[bot] authored Jan 17, 2024
2 parents c58e17d + 9ead3f7 commit 928dedc
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# cabal --help
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-- Andreas Abel, 2024-01-13
--
-- Ensure that the last line of the help text is the name of the config file.
-- This invariant is used by clients such as the Haskell setup github action.
-- See: https://github.com/haskell-actions/setup/pull/63

import Distribution.Utils.String (trim)
import Test.Cabal.Prelude

main = cabalTest $ do
env <- getTestEnv
res <- cabal' "--help" []

-- The end of the help text should be something like:
--
-- > You can edit the cabal configuration file to set defaults:
-- > <<HOME>>/.cabal/config
--
-- So trimming the last line will give us the name of the config file.
let configFile = trim . last . lines . resultOutput $ res

-- Verify that this is indeed the config file.
assertEqual "Last line of help text should be name of the config file"
(testUserCabalConfigFile env)
configFile

0 comments on commit 928dedc

Please sign in to comment.