-
Notifications
You must be signed in to change notification settings - Fork 698
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9614 from haskell/test-help-prints-config-file
Test that the last line `--help` is the name of the config file
- Loading branch information
Showing
2 changed files
with
26 additions
and
0 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
cabal-testsuite/PackageTests/Help/HelpPrintsConfigFile/help-prints-config-file.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# cabal --help |
25 changes: 25 additions & 0 deletions
25
cabal-testsuite/PackageTests/Help/HelpPrintsConfigFile/help-prints-config-file.test.hs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |