Skip to content

Commit b71d7a3

Browse files
authored
Merge pull request #9013 from Kleidukos/backport-no-check-pvp-internal-3.10
Do not check PVP on internal targets (backport of #9004 to 3.10)
2 parents 6baf1e4 + 584fc87 commit b71d7a3

File tree

7 files changed

+52
-8
lines changed

7 files changed

+52
-8
lines changed

Cabal/src/Distribution/PackageDescription/Check.hs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ import System.FilePath
7070

7171
import qualified Data.ByteString.Lazy as BS
7272
import qualified Data.Map as Map
73+
import qualified Control.Monad as CM
7374
import qualified Distribution.Compat.DList as DList
7475
import qualified Distribution.SPDX as SPDX
7576
import qualified System.Directory as System
@@ -1899,14 +1900,24 @@ checkPackageVersions pkg =
18991900
baseErrors
19001901
where
19011902
baseErrors = PackageDistInexcusable BaseNoUpperBounds <$ bases
1902-
deps = toDependencyVersionsMap allBuildDepends pkg
1903+
deps = toDependencyVersionsMap allNonInternalBuildDepends pkg
19031904
-- base gets special treatment (it's more critical)
19041905
(bases, others) = partition (("base" ==) . unPackageName) $
19051906
[ name
19061907
| (name, vr) <- Map.toList deps
19071908
, not (hasUpperBound vr)
19081909
]
19091910

1911+
-- Get the combined build-depends entries of all components.
1912+
allNonInternalBuildDepends :: PackageDescription -> [Dependency]
1913+
allNonInternalBuildDepends = targetBuildDepends CM.<=< allNonInternalBuildInfo
1914+
1915+
allNonInternalBuildInfo :: PackageDescription -> [BuildInfo]
1916+
allNonInternalBuildInfo pkg_descr =
1917+
[bi | lib <- allLibraries pkg_descr, let bi = libBuildInfo lib]
1918+
++ [bi | flib <- foreignLibs pkg_descr, let bi = foreignLibBuildInfo flib]
1919+
++ [bi | exe <- executables pkg_descr, let bi = buildInfo exe]
1920+
19101921
checkConditionals :: GenericPackageDescription -> [PackageCheck]
19111922
checkConditionals pkg =
19121923
catMaybes [

cabal-install/cabal-install.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ test-suite unit-tests
336336
tasty-quickcheck,
337337
tasty-hunit >= 0.10,
338338
tree-diff,
339-
QuickCheck >= 2.14 && <2.15
339+
QuickCheck >= 2.14.3 && <2.15
340340

341341

342342
-- Tests to run with a limited stack and heap size

cabal-install/tests/UnitTests/Distribution/Client/ArbitraryInstances.hs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ import Distribution.Solver.Types.PackageConstraint (PackageProperty (..))
4444
import Data.Coerce (Coercible, coerce)
4545
import Network.URI (URI (..), URIAuth (..), isUnreserved)
4646
import Test.QuickCheck
47-
import Test.QuickCheck.GenericArbitrary
47+
import Test.QuickCheck.GenericArbitrary (genericArbitrary)
4848
import Test.QuickCheck.Instances.Cabal ()
4949

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

110-
shrinkBoundedEnum :: (Eq a, Enum a, Bounded a) => a -> [a]
111-
shrinkBoundedEnum x
112-
| x == minBound = []
113-
| otherwise = [pred x]
114-
115110
adjustSize :: (Int -> Int) -> Gen a -> Gen a
116111
adjustSize adjust gen = sized (\n -> resize (adjust n) gen)
117112

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# cabal check
2+
No errors or warnings could be found in the package.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import Test.Cabal.Prelude
2+
3+
-- Internal targets (tests, benchmarks) should not be checked.
4+
main = cabalTest $
5+
cabal "check" []
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
cabal-version: 3.0
2+
name: pkg
3+
synopsis: synopsis
4+
description: description
5+
version: 0
6+
category: example
7+
maintainer: [email protected]
8+
license: GPL-3.0-or-later
9+
10+
library
11+
exposed-modules: Foo
12+
default-language: Haskell2010
13+
build-depends: base == 2.2.*
14+
15+
test-suite test
16+
type: exitcode-stdio-1.0
17+
main-is: Test.hs
18+
default-language: Haskell2010
19+
build-depends: base == 2.2.*,
20+
criterion

changelog.d/pr-9004

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
synopsis: Do not check PVP on internal targets
2+
packages: cabal-install
3+
prs: #9004
4+
issues: #8361
5+
6+
description: {
7+
8+
- `cabal check` will not check for dependencies upper bounds in internal
9+
targets (i.e. test-suites and benchmarks)
10+
11+
}

0 commit comments

Comments
 (0)