diff --git a/cabal-install/src/Distribution/Client/Init/Format.hs b/cabal-install/src/Distribution/Client/Init/Format.hs index 0f4bf3d7e74..8ba29ce9bce 100644 --- a/cabal-install/src/Distribution/Client/Init/Format.hs +++ b/cabal-install/src/Distribution/Client/Init/Format.hs @@ -314,80 +314,75 @@ mkExeStanza opts (ExeTarget exeMain appDirs lang otherMods exts deps tools) = mkTestStanza :: WriteOpts -> TestTarget -> PrettyField FieldAnnotation mkTestStanza opts (TestTarget testMain dirs lang otherMods exts deps tools) = - PrettySection - annNoComments - (toUTF8BS "test-suite") - [suiteName] - ( insertCommonStanzas opts - ++ insertRtsOptionsStanza opts - ++ [ case specHasCommonStanzas $ _optCabalSpec opts of - NoCommonStanzas -> PrettyEmpty - _ -> - field - "import" - (hsep . map text) - ["warnings"] - ["Import common warning flags."] + let commonSections = + case specHasCommonStanzas $ _optCabalSpec opts of + NoCommonStanzas -> [PrettyEmpty] + _ -> + insertCommonStanzas opts + ++ insertRtsOptionsStanza opts + in PrettySection + annNoComments + (toUTF8BS "test-suite") + [suiteName] + ( commonSections + ++ [ field + "default-language" + id + lang + ["Base language which the package is written in."] + True + opts + , field + "other-modules" + formatOtherModules + otherMods + ["Modules included in this executable, other than Main."] + True + opts + , field + "other-extensions" + formatOtherExtensions + exts + ["LANGUAGE extensions used by modules in this package."] + True + opts + , field + "type" + text + "exitcode-stdio-1.0" + ["The interface type and version of the test suite."] + True + opts + , field + "hs-source-dirs" + formatHsSourceDirs + (makeSymbolicPath <$> dirs) + ["Directories containing source files."] + True + opts + , field + "main-is" + unsafeFromHs + testMain + ["The entrypoint to the test suite."] + True + opts + , field + "build-depends" + formatDependencyList + deps + ["Test dependencies."] + True + opts + , field + (buildToolTag opts) + formatDependencyList + tools + ["Extra tools (e.g. alex, hsc2hs, ...) needed to build the source."] False opts - , field - "default-language" - id - lang - ["Base language which the package is written in."] - True - opts - , field - "other-modules" - formatOtherModules - otherMods - ["Modules included in this executable, other than Main."] - True - opts - , field - "other-extensions" - formatOtherExtensions - exts - ["LANGUAGE extensions used by modules in this package."] - True - opts - , field - "type" - text - "exitcode-stdio-1.0" - ["The interface type and version of the test suite."] - True - opts - , field - "hs-source-dirs" - formatHsSourceDirs - (makeSymbolicPath <$> dirs) - ["Directories containing source files."] - True - opts - , field - "main-is" - unsafeFromHs - testMain - ["The entrypoint to the test suite."] - True - opts - , field - "build-depends" - formatDependencyList - deps - ["Test dependencies."] - True - opts - , field - (buildToolTag opts) - formatDependencyList - tools - ["Extra tools (e.g. alex, hsc2hs, ...) needed to build the source."] - False - opts - ] - ) + ] + ) where suiteName = text $ unPackageName (_optPkgName opts) ++ "-test" diff --git a/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-and-exe-no-comments.golden b/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-and-exe-no-comments.golden index e60cbd3e35e..f7cc439ffde 100644 --- a/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-and-exe-no-comments.golden +++ b/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-and-exe-no-comments.golden @@ -54,7 +54,6 @@ test-suite y-test import: extensions import: ghc-options import: rts-options - import: warnings default-language: Haskell2010 -- other-modules: -- other-extensions: diff --git a/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-and-exe-with-comments.golden b/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-and-exe-with-comments.golden index 60c743daf07..f639f3ce3c5 100644 --- a/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-and-exe-with-comments.golden +++ b/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-and-exe-with-comments.golden @@ -130,9 +130,6 @@ test-suite y-test -- Common RTS options import: rts-options - -- Import common warning flags. - import: warnings - -- Base language which the package is written in. default-language: Haskell2010 diff --git a/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-no-comments.golden b/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-no-comments.golden index a68f072b787..0aea9e77a9a 100644 --- a/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-no-comments.golden +++ b/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-no-comments.golden @@ -40,7 +40,6 @@ test-suite y-test import: extensions import: ghc-options import: rts-options - import: warnings default-language: Haskell2010 -- other-modules: -- other-extensions: diff --git a/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-with-comments.golden b/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-with-comments.golden index 1f105d0188d..e0c5862a62a 100644 --- a/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-with-comments.golden +++ b/cabal-install/tests/fixtures/init/golden/cabal/cabal-lib-with-comments.golden @@ -100,9 +100,6 @@ test-suite y-test -- Common RTS options import: rts-options - -- Import common warning flags. - import: warnings - -- Base language which the package is written in. default-language: Haskell2010 diff --git a/cabal-install/tests/fixtures/init/golden/cabal/cabal-test-suite-no-comments.golden b/cabal-install/tests/fixtures/init/golden/cabal/cabal-test-suite-no-comments.golden index 87e91b0cfe6..f6a720eee95 100644 --- a/cabal-install/tests/fixtures/init/golden/cabal/cabal-test-suite-no-comments.golden +++ b/cabal-install/tests/fixtures/init/golden/cabal/cabal-test-suite-no-comments.golden @@ -30,7 +30,6 @@ test-suite y-test import: extensions import: ghc-options import: rts-options - import: warnings default-language: Haskell2010 -- other-modules: -- other-extensions: diff --git a/cabal-install/tests/fixtures/init/golden/cabal/cabal-test-suite-with-comments.golden b/cabal-install/tests/fixtures/init/golden/cabal/cabal-test-suite-with-comments.golden index 0141265065e..bfb5d73b431 100644 --- a/cabal-install/tests/fixtures/init/golden/cabal/cabal-test-suite-with-comments.golden +++ b/cabal-install/tests/fixtures/init/golden/cabal/cabal-test-suite-with-comments.golden @@ -75,9 +75,6 @@ test-suite y-test -- Common RTS options import: rts-options - -- Import common warning flags. - import: warnings - -- Base language which the package is written in. default-language: Haskell2010 diff --git a/cabal-install/tests/fixtures/init/golden/test/standalone-test-no-comments.golden b/cabal-install/tests/fixtures/init/golden/test/standalone-test-no-comments.golden index b6c007b4b69..f0ac297b5bb 100644 --- a/cabal-install/tests/fixtures/init/golden/test/standalone-test-no-comments.golden +++ b/cabal-install/tests/fixtures/init/golden/test/standalone-test-no-comments.golden @@ -2,7 +2,6 @@ test-suite y-test import: extensions import: ghc-options import: rts-options - import: warnings default-language: Haskell2010 -- other-modules: -- other-extensions: diff --git a/cabal-install/tests/fixtures/init/golden/test/standalone-test-with-comments.golden b/cabal-install/tests/fixtures/init/golden/test/standalone-test-with-comments.golden index 2d2391d3736..7e8d707f428 100644 --- a/cabal-install/tests/fixtures/init/golden/test/standalone-test-with-comments.golden +++ b/cabal-install/tests/fixtures/init/golden/test/standalone-test-with-comments.golden @@ -8,9 +8,6 @@ test-suite y-test -- Common RTS options import: rts-options - -- Import common warning flags. - import: warnings - -- Base language which the package is written in. default-language: Haskell2010 diff --git a/cabal-install/tests/fixtures/init/golden/test/test-build-tools-with-comments.golden b/cabal-install/tests/fixtures/init/golden/test/test-build-tools-with-comments.golden index e76c8205096..c0ec7221679 100644 --- a/cabal-install/tests/fixtures/init/golden/test/test-build-tools-with-comments.golden +++ b/cabal-install/tests/fixtures/init/golden/test/test-build-tools-with-comments.golden @@ -8,9 +8,6 @@ test-suite y-test -- Common RTS options import: rts-options - -- Import common warning flags. - import: warnings - -- Base language which the package is written in. default-language: Haskell2010 diff --git a/cabal-install/tests/fixtures/init/golden/test/test-minimal-no-comments.golden b/cabal-install/tests/fixtures/init/golden/test/test-minimal-no-comments.golden index 364652831c8..b90e0413f00 100644 --- a/cabal-install/tests/fixtures/init/golden/test/test-minimal-no-comments.golden +++ b/cabal-install/tests/fixtures/init/golden/test/test-minimal-no-comments.golden @@ -2,7 +2,6 @@ test-suite y-test import: extensions import: ghc-options import: rts-options - import: warnings default-language: Haskell2010 type: exitcode-stdio-1.0 hs-source-dirs: test diff --git a/cabal-install/tests/fixtures/init/golden/test/test-no-comments.golden b/cabal-install/tests/fixtures/init/golden/test/test-no-comments.golden index b6c007b4b69..f0ac297b5bb 100644 --- a/cabal-install/tests/fixtures/init/golden/test/test-no-comments.golden +++ b/cabal-install/tests/fixtures/init/golden/test/test-no-comments.golden @@ -2,7 +2,6 @@ test-suite y-test import: extensions import: ghc-options import: rts-options - import: warnings default-language: Haskell2010 -- other-modules: -- other-extensions: diff --git a/cabal-install/tests/fixtures/init/golden/test/test-simple-minimal-with-comments.golden b/cabal-install/tests/fixtures/init/golden/test/test-simple-minimal-with-comments.golden index 364652831c8..b90e0413f00 100644 --- a/cabal-install/tests/fixtures/init/golden/test/test-simple-minimal-with-comments.golden +++ b/cabal-install/tests/fixtures/init/golden/test/test-simple-minimal-with-comments.golden @@ -2,7 +2,6 @@ test-suite y-test import: extensions import: ghc-options import: rts-options - import: warnings default-language: Haskell2010 type: exitcode-stdio-1.0 hs-source-dirs: test diff --git a/cabal-install/tests/fixtures/init/golden/test/test-with-comments.golden b/cabal-install/tests/fixtures/init/golden/test/test-with-comments.golden index 2d2391d3736..7e8d707f428 100644 --- a/cabal-install/tests/fixtures/init/golden/test/test-with-comments.golden +++ b/cabal-install/tests/fixtures/init/golden/test/test-with-comments.golden @@ -8,9 +8,6 @@ test-suite y-test -- Common RTS options import: rts-options - -- Import common warning flags. - import: warnings - -- Base language which the package is written in. default-language: Haskell2010