Skip to content

Commit

Permalink
Add test for #9331
Browse files Browse the repository at this point in the history
- `cabal check`: Guard Paths_* behind `cabal-version: 3.12` or higher,
  “fail” and “succeed” tests.
- `cabal build`: Guard Paths_* behind `cabal-version: 3.12` or higher,
  “fail” test.
  • Loading branch information
ffaf1 committed Dec 15, 2023
1 parent 43c3cc0 commit 655c6af
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 0 deletions.
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,2 @@
packages: .

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: `pkg`).
autogen-modules: PackageInfo_pkg
exposed-modules: PackageInfo_pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 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: Hackage would reject this package.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import Test.Cabal.Prelude

-- #9331: PackageInfo functionality should be guarded by cabal-version.
main = cabalTest $
fails $ cabal "check" []

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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 <5
autogen-modules: PackageInfo_pkg
exposed-modules: PackageInfo_pkg

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# cabal check
No errors or warnings could be found in the package.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import Test.Cabal.Prelude

-- #9331: PackageInfo functionality should be guarded by cabal-version,
-- does not error when cabal-version is 3.12 or higher.
main = cabalTest $
cabal "check" []

Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
cabal-version: 3.12
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 <5
autogen-modules: PackageInfo_pkg
exposed-modules: PackageInfo_pkg

0 comments on commit 655c6af

Please sign in to comment.