Skip to content

Commit

Permalink
Add Mikolaj’s test
Browse files Browse the repository at this point in the history
i.e. fail on build. This means the error is no more “just” a
PackageDistInexcusable (Hackage will refuse it), *but* a
PackageBuildImpossible.
  • Loading branch information
ffaf1 committed Dec 7, 2023
1 parent a61c433 commit b7acbf4
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 5 deletions.
4 changes: 3 additions & 1 deletion Cabal/src/Distribution/PackageDescription/Check/Target.hs
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,9 @@ checkAutogenModules ams bi = do
checkSpecVer
CabalSpecV3_12
(elem autoInfoModuleName allModsForAuto)
(PackageDistInexcusable CVAutogenPackageInfoGuard)
(PackageBuildImpossible CVAutogenPackageInfoGuard)
-- See Mikolaj’s comments on #9481 on why this has to be
-- PackageBuildImpossible and not merely PackageDistInexcusable.
where
allModsForAuto :: [ModuleName]
allModsForAuto = ams ++ otherModules bi
Expand Down
10 changes: 10 additions & 0 deletions cabal-testsuite/PackageTests/BuildAutogenPackageGuard/cabal.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# cabal v2-build
Resolving dependencies...
Build profile: -w ghc-<GHCVER> -O1
In order, the following will be built:
- pkg-0 (lib) (first run)
Configuring library for pkg-0...
Error: [Cabal-5559]
To use the autogenerated module PackageInfo_* you need to specify `cabal-version: 3.12` or higher.
Error: [Cabal-7125]
Failed to build pkg-0-inplace. The failure occurred during the configure step.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
packages: .

source-repository-package
type: git
-- A Sample repo to test post-checkout-command
location: https://github.com/haskell/bytestring
post-checkout-command: true
tag: 0.10.9.0
-- https://en.wikipedia.org/wiki/True_and_false_(commands)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import Test.Cabal.Prelude

-- #9331, guard PackageInfo functionality behind 3.12: make it a
-- build failure.
main = cabalTest $ do
withProjectFile "cabal.project" $ do
fails $ cabal "v2-build" ["pkg"]

17 changes: 17 additions & 0 deletions cabal-testsuite/PackageTests/BuildAutogenPackageGuard/pkg.cabal
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
cabal-version: 2.4
name: pkg
version: 0
license: GPL-3.0-or-later
maintainer: Someone
category: Example
synopsis: Foo
description: FooBar
build-type: Simple

library
default-language: Haskell2010
build-depends: base == 4.*
-- ☞ N.B.: PackageInfo packages must contain the same name of
-- of the package! (In this example: `prova`).
autogen-modules: PackageInfo_pkg
exposed-modules: PackageInfo_pkg
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# cabal check
The package will not build sanely due to these errors:
Error: To use the autogenerated module PackageInfo_* you need to specify `cabal-version: 3.12` or higher.
The following errors will cause portability problems on other environments:
Error: Packages using 'cabal-version: 2.0' and the autogenerated module Paths_* must include it also on the 'autogen-modules' field besides 'exposed-modules' and 'other-modules'. This specifies that the module does not come with the package and is generated on setup. Modules built with a custom Setup.hs script also go here to ensure that commands like sdist don't fail.
Error: Packages using 'cabal-version: 2.0' and the autogenerated module PackageInfo_* must include it in 'autogen-modules' as well as 'exposed-modules' and 'other-modules'. This specifies that the module does not come with the package and is generated on setup. Modules built with a custom Setup.hs script also go here to ensure that commands like sdist don't fail.
Error: To use the autogenerated module PackageInfo_* you need to specify `cabal-version: 3.12` or higher.
Error: Hackage would reject this package.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# cabal check
The following errors will cause portability problems on other environments:
The package will not build sanely due to these errors:
Error: To use the autogenerated module PackageInfo_* you need to specify `cabal-version: 3.12` or higher.
Error: Hackage would reject this package.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# cabal check
The package will not build sanely due to these errors:
Error: To use the autogenerated module PackageInfo_* you need to specify `cabal-version: 3.12` or higher.
Error: Packages using RebindableSyntax with OverloadedStrings or OverloadedLists in default-extensions, in conjunction with the autogenerated module Paths_*, are known to cause compile failures with Cabal < 2.2. To use these default-extensions with a Paths_* autogen module, specify at least 'cabal-version: 2.2'.
Error: Packages using RebindableSyntax with OverloadedStrings or OverloadedLists in default-extensions, in conjunction with the autogenerated module PackageInfo_*, are known to cause compile failures with Cabal < 2.2. To use these default-extensions with a PackageInfo_* autogen module, specify at least 'cabal-version: 2.2'.
The following errors will cause portability problems on other environments:
Error: To use the autogenerated module PackageInfo_* you need to specify `cabal-version: 3.12` or higher.
Error: Hackage would reject this package.

0 comments on commit b7acbf4

Please sign in to comment.