From 1cb92a38c016fe0b0af2b5c0aa1d448e675f0ab1 Mon Sep 17 00:00:00 2001 From: ffaf1 Date: Sun, 11 Jun 2023 12:31:00 +0200 Subject: [PATCH] Do not check PVP on internal targets (#9004) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * Do not check PVP on internal targets Internal targets: test-suites or benchmarks. See #8361 for rationale. Note that this patch is quite ugly (duplicating allBuildInfo, using list comprehensions, etc.) but we don’t care as everything will be overwritten by a much more sensible reimplementation in #8427. * Add changelog for #9004 --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> --- Cabal/src/Distribution/PackageDescription/Check.hs | 13 ++++++++++++- .../NonConfCheck/PackageVersionsNoCheck/cabal.out | 2 ++ .../PackageVersionsNoCheck/cabal.test.hs | 5 +++++ .../NonConfCheck/PackageVersionsNoCheck/pkg.cabal | 21 +++++++++++++++++++++ changelog.d/pr-9004 | 11 +++++++++++ 5 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 cabal-testsuite/PackageTests/Check/NonConfCheck/PackageVersionsNoCheck/cabal.out create mode 100644 cabal-testsuite/PackageTests/Check/NonConfCheck/PackageVersionsNoCheck/cabal.test.hs create mode 100644 cabal-testsuite/PackageTests/Check/NonConfCheck/PackageVersionsNoCheck/pkg.cabal create mode 100644 changelog.d/pr-9004 diff --git a/Cabal/src/Distribution/PackageDescription/Check.hs b/Cabal/src/Distribution/PackageDescription/Check.hs index b30459507..e8be60fcb 100644 --- a/Cabal/src/Distribution/PackageDescription/Check.hs +++ b/Cabal/src/Distribution/PackageDescription/Check.hs @@ -79,6 +79,7 @@ import System.FilePath , () ) +import qualified Control.Monad as CM import qualified Data.ByteString.Lazy as BS import qualified Data.Map as Map import qualified Distribution.Compat.DList as DList @@ -2109,7 +2110,7 @@ checkPackageVersions pkg = else baseErrors where baseErrors = PackageDistInexcusable BaseNoUpperBounds <$ bases - deps = toDependencyVersionsMap allBuildDepends pkg + deps = toDependencyVersionsMap allNonInternalBuildDepends pkg -- base gets special treatment (it's more critical) (bases, others) = partition (("base" ==) . unPackageName) $ @@ -2118,6 +2119,16 @@ checkPackageVersions pkg = , not (hasUpperBound vr) ] + -- Get the combined build-depends entries of all components. + allNonInternalBuildDepends :: PackageDescription -> [Dependency] + allNonInternalBuildDepends = targetBuildDepends CM.<=< allNonInternalBuildInfo + + allNonInternalBuildInfo :: PackageDescription -> [BuildInfo] + allNonInternalBuildInfo pkg_descr = + [bi | lib <- allLibraries pkg_descr, let bi = libBuildInfo lib] + ++ [bi | flib <- foreignLibs pkg_descr, let bi = foreignLibBuildInfo flib] + ++ [bi | exe <- executables pkg_descr, let bi = buildInfo exe] + checkConditionals :: GenericPackageDescription -> [PackageCheck] checkConditionals pkg = catMaybes diff --git a/cabal-testsuite/PackageTests/Check/NonConfCheck/PackageVersionsNoCheck/cabal.out b/cabal-testsuite/PackageTests/Check/NonConfCheck/PackageVersionsNoCheck/cabal.out new file mode 100644 index 000000000..37aa169b4 --- /dev/null +++ b/cabal-testsuite/PackageTests/Check/NonConfCheck/PackageVersionsNoCheck/cabal.out @@ -0,0 +1,2 @@ +# cabal check +No errors or warnings could be found in the package. diff --git a/cabal-testsuite/PackageTests/Check/NonConfCheck/PackageVersionsNoCheck/cabal.test.hs b/cabal-testsuite/PackageTests/Check/NonConfCheck/PackageVersionsNoCheck/cabal.test.hs new file mode 100644 index 000000000..70228e5a4 --- /dev/null +++ b/cabal-testsuite/PackageTests/Check/NonConfCheck/PackageVersionsNoCheck/cabal.test.hs @@ -0,0 +1,5 @@ +import Test.Cabal.Prelude + +-- Internal targets (tests, benchmarks) should not be checked. +main = cabalTest $ + cabal "check" [] diff --git a/cabal-testsuite/PackageTests/Check/NonConfCheck/PackageVersionsNoCheck/pkg.cabal b/cabal-testsuite/PackageTests/Check/NonConfCheck/PackageVersionsNoCheck/pkg.cabal new file mode 100644 index 000000000..5b9486294 --- /dev/null +++ b/cabal-testsuite/PackageTests/Check/NonConfCheck/PackageVersionsNoCheck/pkg.cabal @@ -0,0 +1,21 @@ +cabal-version: 3.0 +name: pkg +synopsis: synopsis +description: description +version: 0 +category: example +maintainer: none@example.com +license: GPL-3.0-or-later + +library + exposed-modules: Foo + default-language: Haskell2010 + build-depends: base == 2.2.* + +test-suite test + type: exitcode-stdio-1.0 + main-is: Test.hs + default-language: Haskell2010 + build-depends: base == 2.2.*, + criterion + diff --git a/changelog.d/pr-9004 b/changelog.d/pr-9004 new file mode 100644 index 000000000..6ff907464 --- /dev/null +++ b/changelog.d/pr-9004 @@ -0,0 +1,11 @@ +synopsis: Do not check PVP on internal targets +packages: cabal-install +prs: #9004 +issues: #8361 + +description: { + +- `cabal check` will not check for dependencies upper bounds in internal + targets (i.e. test-suites and benchmarks) + +} -- 2.11.4.GIT