Skip to content

Commit 011259e

Browse files
committed
add test for cabal/config
1 parent 6372ec2 commit 011259e

4 files changed

Lines changed: 23 additions & 2 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# cabal user-config
2+
Writing default configuration to <ROOT>/cabal.dist/cabal-config
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import Test.Cabal.Prelude
2+
import Data.List (isInfixOf, groupBy)
3+
import Data.Function (on)
4+
5+
main = cabalTest $ do
6+
workdir <- fmap testWorkDir getTestEnv
7+
let conf = workdir </> "cabal-config"
8+
9+
cabalG ["--config-file", conf] "user-config" ["init"]
10+
confContents <- liftIO $ readFile conf
11+
12+
let ls = lines confContents
13+
sections = groupBy ((==) `on` (== "")) ls
14+
[initLs] = filter ((== "-- full-version: False") . head) sections
15+
init = unlines initLs
16+
17+
assertBool "init section of config should contain debug-info: 0" ("debug-info: 0" `isInfixOf` init)
18+
assertBool "init section of config should contain optimization: 1" ("optimization: 1" `isInfixOf` init)

cabal-testsuite/PackageTests/ProjectConfig/FlagsBools/cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ packages: .
22

33
build-info: true
44
optimization: tRuE
5+
debug-info: fALSe
56

67
package test
78
flags: -bar

changelog.d/11937.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ prs: 11937
55
---
66

77
The rendering of certain boolean‑like flags has been changed to use numeric levels:
8-
- For the `-O` (optimisation) flag, `True` or an unspecified value now renders as `-O1`, while `False` renders as `-O0`.
9-
- For the `-g` (debug info) flag, `True` or an unspecified value now renders `-g2`, while `False` renders as `-g0`.
8+
- For the `-O` (optimisation) flag, `True` or an unspecified value now renders as `1`, while `False` renders as `0`.
9+
- For the `-g` (debug info) flag, `True` or an unspecified value now renders `2`, while `False` renders as `0`.
1010
This makes the displayed compiler flags more consistent with their internal semantics (e.g. optimisation level 1 is the default).

0 commit comments

Comments
 (0)