Merge pull request #10546 from cabalism/fix/dedup-using-config-from
[cabal.git] / cabal-testsuite / PackageTests / ConfigFile / InitSectionFields / cabal.test.hs
blobac7c93345f79c67b00060c35e85d403e4213a100
1 import Test.Cabal.Prelude
2 import Data.List ( isInfixOf, groupBy )
3 import Data.Function ( on )
5 main = cabalTest $ do
6 workdir <- fmap testWorkDir getTestEnv
7 let conf = workdir </> "cabal-config"
8 cabalG ["--config-file", conf] "user-config" ["init"]
9 confContents <- liftIO $ readFile conf
10 let ls = lines confContents
11 sections = groupBy ((==) `on` (== "")) ls
12 [initLs] = filter ((== "init") . head) sections
13 init = unlines initLs
14 assertInitSectionContainsField init "quiet"
15 assertInitSectionContainsField init "no-comments"
16 assertInitSectionContainsField init "minimal"
17 assertInitSectionContainsField init "simple"
19 assertInitSectionContainsField section field =
20 assertBool ("init section of config should contain the field " ++ field)
21 ((field ++ ":") `isInfixOf` section)