Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not check PVP on internal targets (backport of #9004 to 3.10) #9013

Merged
merged 2 commits into from
Jun 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be indented the same way? (gremlins…)

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
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)

}