Skip to content

Commit

Permalink
Do not check PVP on internal targets (haskell#9004)
Browse files Browse the repository at this point in the history
Internal targets: test-suites or benchmarks.
See haskell#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 haskell#8427.
  • Loading branch information
Kleidukos committed Jun 12, 2023
1 parent 6baf1e4 commit e762fbc
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Cabal/src/Distribution/PackageDescription/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ import System.FilePath

import qualified Data.ByteString.Lazy as BS
import qualified Data.Map as Map
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
import qualified Distribution.SPDX as SPDX
import qualified System.Directory as System
Expand Down Expand Up @@ -1899,14 +1902,24 @@ checkPackageVersions pkg =
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) $
[ name
| (name, vr) <- Map.toList deps
, 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 [
Expand Down
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,5 @@
import Test.Cabal.Prelude

-- Internal targets (tests, benchmarks) should not be checked.
main = cabalTest $
cabal "check" []
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
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
11 changes: 11 additions & 0 deletions changelog.d/pr-9004
Original file line number Diff line number Diff line change
@@ -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)

}

0 comments on commit e762fbc

Please sign in to comment.