Skip to content

Commit ac43ae5

Browse files
committed
Remove old warnings section in generated cabal files
This is a follow-up to haskell#11261
1 parent 65f9507 commit ac43ae5

14 files changed

Lines changed: 67 additions & 97 deletions

cabal-install/src/Distribution/Client/Init/Format.hs

Lines changed: 67 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -314,80 +314,75 @@ mkExeStanza opts (ExeTarget exeMain appDirs lang otherMods exts deps tools) =
314314

315315
mkTestStanza :: WriteOpts -> TestTarget -> PrettyField FieldAnnotation
316316
mkTestStanza opts (TestTarget testMain dirs lang otherMods exts deps tools) =
317-
PrettySection
318-
annNoComments
319-
(toUTF8BS "test-suite")
320-
[suiteName]
321-
( insertCommonStanzas opts
322-
++ insertRtsOptionsStanza opts
323-
++ [ case specHasCommonStanzas $ _optCabalSpec opts of
324-
NoCommonStanzas -> PrettyEmpty
325-
_ ->
326-
field
327-
"import"
328-
(hsep . map text)
329-
["warnings"]
330-
["Import common warning flags."]
317+
let commonSections =
318+
case specHasCommonStanzas $ _optCabalSpec opts of
319+
NoCommonStanzas -> [PrettyEmpty]
320+
_ ->
321+
insertCommonStanzas opts
322+
++ insertRtsOptionsStanza opts
323+
in PrettySection
324+
annNoComments
325+
(toUTF8BS "test-suite")
326+
[suiteName]
327+
( commonSections
328+
++ [ field
329+
"default-language"
330+
id
331+
lang
332+
["Base language which the package is written in."]
333+
True
334+
opts
335+
, field
336+
"other-modules"
337+
formatOtherModules
338+
otherMods
339+
["Modules included in this executable, other than Main."]
340+
True
341+
opts
342+
, field
343+
"other-extensions"
344+
formatOtherExtensions
345+
exts
346+
["LANGUAGE extensions used by modules in this package."]
347+
True
348+
opts
349+
, field
350+
"type"
351+
text
352+
"exitcode-stdio-1.0"
353+
["The interface type and version of the test suite."]
354+
True
355+
opts
356+
, field
357+
"hs-source-dirs"
358+
formatHsSourceDirs
359+
(makeSymbolicPath <$> dirs)
360+
["Directories containing source files."]
361+
True
362+
opts
363+
, field
364+
"main-is"
365+
unsafeFromHs
366+
testMain
367+
["The entrypoint to the test suite."]
368+
True
369+
opts
370+
, field
371+
"build-depends"
372+
formatDependencyList
373+
deps
374+
["Test dependencies."]
375+
True
376+
opts
377+
, field
378+
(buildToolTag opts)
379+
formatDependencyList
380+
tools
381+
["Extra tools (e.g. alex, hsc2hs, ...) needed to build the source."]
331382
False
332383
opts
333-
, field
334-
"default-language"
335-
id
336-
lang
337-
["Base language which the package is written in."]
338-
True
339-
opts
340-
, field
341-
"other-modules"
342-
formatOtherModules
343-
otherMods
344-
["Modules included in this executable, other than Main."]
345-
True
346-
opts
347-
, field
348-
"other-extensions"
349-
formatOtherExtensions
350-
exts
351-
["LANGUAGE extensions used by modules in this package."]
352-
True
353-
opts
354-
, field
355-
"type"
356-
text
357-
"exitcode-stdio-1.0"
358-
["The interface type and version of the test suite."]
359-
True
360-
opts
361-
, field
362-
"hs-source-dirs"
363-
formatHsSourceDirs
364-
(makeSymbolicPath <$> dirs)
365-
["Directories containing source files."]
366-
True
367-
opts
368-
, field
369-
"main-is"
370-
unsafeFromHs
371-
testMain
372-
["The entrypoint to the test suite."]
373-
True
374-
opts
375-
, field
376-
"build-depends"
377-
formatDependencyList
378-
deps
379-
["Test dependencies."]
380-
True
381-
opts
382-
, field
383-
(buildToolTag opts)
384-
formatDependencyList
385-
tools
386-
["Extra tools (e.g. alex, hsc2hs, ...) needed to build the source."]
387-
False
388-
opts
389-
]
390-
)
384+
]
385+
)
391386
where
392387
suiteName = text $ unPackageName (_optPkgName opts) ++ "-test"
393388

cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-and-exe-no-comments.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ test-suite y-test
5454
import: extensions
5555
import: ghc-options
5656
import: rts-options
57-
import: warnings
5857
default-language: Haskell2010
5958
-- other-modules:
6059
-- other-extensions:

cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-and-exe-with-comments.golden

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,6 @@ test-suite y-test
130130
-- Common RTS options
131131
import: rts-options
132132

133-
-- Import common warning flags.
134-
import: warnings
135-
136133
-- Base language which the package is written in.
137134
default-language: Haskell2010
138135

cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-no-comments.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ test-suite y-test
4040
import: extensions
4141
import: ghc-options
4242
import: rts-options
43-
import: warnings
4443
default-language: Haskell2010
4544
-- other-modules:
4645
-- other-extensions:

cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-with-comments.golden

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ test-suite y-test
100100
-- Common RTS options
101101
import: rts-options
102102

103-
-- Import common warning flags.
104-
import: warnings
105-
106103
-- Base language which the package is written in.
107104
default-language: Haskell2010
108105

cabal-install/tests/fixtures/init/golden/cabal/cabal-test-suite-no-comments.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ test-suite y-test
3030
import: extensions
3131
import: ghc-options
3232
import: rts-options
33-
import: warnings
3433
default-language: Haskell2010
3534
-- other-modules:
3635
-- other-extensions:

cabal-install/tests/fixtures/init/golden/cabal/cabal-test-suite-with-comments.golden

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ test-suite y-test
7575
-- Common RTS options
7676
import: rts-options
7777

78-
-- Import common warning flags.
79-
import: warnings
80-
8178
-- Base language which the package is written in.
8279
default-language: Haskell2010
8380

cabal-install/tests/fixtures/init/golden/test/standalone-test-no-comments.golden

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ test-suite y-test
22
import: extensions
33
import: ghc-options
44
import: rts-options
5-
import: warnings
65
default-language: Haskell2010
76
-- other-modules:
87
-- other-extensions:

cabal-install/tests/fixtures/init/golden/test/standalone-test-with-comments.golden

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ test-suite y-test
88
-- Common RTS options
99
import: rts-options
1010

11-
-- Import common warning flags.
12-
import: warnings
13-
1411
-- Base language which the package is written in.
1512
default-language: Haskell2010
1613

cabal-install/tests/fixtures/init/golden/test/test-build-tools-with-comments.golden

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ test-suite y-test
88
-- Common RTS options
99
import: rts-options
1010

11-
-- Import common warning flags.
12-
import: warnings
13-
1411
-- Base language which the package is written in.
1512
default-language: Haskell2010
1613

0 commit comments

Comments
 (0)