Skip to content

Commit

Permalink
Merge pull request #9013 from Kleidukos/backport-no-check-pvp-interna…
Browse files Browse the repository at this point in the history
…l-3.10

Do not check PVP on internal targets (backport of #9004 to 3.10)
  • Loading branch information
mergify[bot] authored Jun 17, 2023
2 parents 6baf1e4 + 584fc87 commit b71d7a3
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 8 deletions.
13 changes: 12 additions & 1 deletion Cabal/src/Distribution/PackageDescription/Check.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import System.FilePath

import qualified Data.ByteString.Lazy as BS
import qualified Data.Map as Map
import qualified Control.Monad as CM
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 +1900,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
2 changes: 1 addition & 1 deletion cabal-install/cabal-install.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ test-suite unit-tests
tasty-quickcheck,
tasty-hunit >= 0.10,
tree-diff,
QuickCheck >= 2.14 && <2.15
QuickCheck >= 2.14.3 && <2.15


-- Tests to run with a limited stack and heap size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import Distribution.Solver.Types.PackageConstraint (PackageProperty (..))
import Data.Coerce (Coercible, coerce)
import Network.URI (URI (..), URIAuth (..), isUnreserved)
import Test.QuickCheck
import Test.QuickCheck.GenericArbitrary
import Test.QuickCheck.GenericArbitrary (genericArbitrary)
import Test.QuickCheck.Instances.Cabal ()

-- note: there are plenty of instances defined in ProjectConfig test file.
Expand Down Expand Up @@ -107,11 +107,6 @@ arbitraryURIPort =
-- cabal-install (and Cabal) types
-------------------------------------------------------------------------------

shrinkBoundedEnum :: (Eq a, Enum a, Bounded a) => a -> [a]
shrinkBoundedEnum x
| x == minBound = []
| otherwise = [pred x]

adjustSize :: (Int -> Int) -> Gen a -> Gen a
adjustSize adjust gen = sized (\n -> resize (adjust n) gen)

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 b71d7a3

Please sign in to comment.