Skip to content

Commit

Permalink
Test that the last line --help is the name of the config file
Browse files Browse the repository at this point in the history
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: haskell-actions/setup#63
  • Loading branch information
andreasabel authored and Mikolaj committed Jan 17, 2024
1 parent c58e17d commit 9ead3f7
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 9ead3f7

Please sign in to comment.