File tree Expand file tree Collapse file tree 10 files changed +55
-5
lines changed
Cabal-syntax/src/Distribution/Types
cabal-install/src/Distribution/Client
cabal-testsuite/PackageTests/ReplBuildDepends Expand file tree Collapse file tree 10 files changed +55
-5
lines changed Original file line number Diff line number Diff line change 11{-# LANGUAGE DeriveDataTypeable #-}
22{-# LANGUAGE DeriveGeneric #-}
33{-# LANGUAGE FlexibleContexts #-}
4- {-# LANGUAGE GeneralizedNewtypeDeriving #-}
54{-# LANGUAGE ScopedTypeVariables #-}
65
76module Distribution.Types.GenericPackageDescription (
@@ -86,15 +85,14 @@ instance L.HasBuildInfos GenericPackageDescription where
8685 <*> (traverse . L. _2 . traverseCondTreeBuildInfo) f x4
8786 <*> (traverse . L. _2 . traverseCondTreeBuildInfo) f x5
8887 <*> (traverse . L. _2 . traverseCondTreeBuildInfo) f x6
89- where
9088
9189-- We use this traversal to keep [Dependency] field in CondTree up to date.
9290traverseCondTreeBuildInfo
9391 :: forall f comp v . (Applicative f , L. HasBuildInfo comp )
9492 => LensLike' f (CondTree v [Dependency ] comp ) L. BuildInfo
9593traverseCondTreeBuildInfo g = node where
9694 mkCondNode :: comp -> [CondBranch v [Dependency ] comp ] -> CondTree v [Dependency ] comp
97- mkCondNode comp branches = CondNode comp (view L. targetBuildDepends comp) branches
95+ mkCondNode comp = CondNode comp (view L. targetBuildDepends comp)
9896
9997 node (CondNode comp _ branches) = mkCondNode
10098 <$> L. buildInfo g comp
Original file line number Diff line number Diff line change @@ -75,7 +75,7 @@ import Distribution.Types.BuildInfo
7575import Distribution.Types.ComponentName
7676 ( componentNameString )
7777import Distribution.Types.CondTree
78- ( CondTree (.. ), traverseCondTreeC )
78+ ( CondTree (.. ) )
7979import Distribution.Types.Dependency
8080 ( Dependency (.. ), mainLibSet )
8181import Distribution.Types.Library
@@ -338,7 +338,12 @@ addDepsToProjectTarget deps pkgId ctx =
338338 | packageId pkg /= pkgId = SpecificSourcePackage pkg
339339 | SourcePackage {.. } <- pkg =
340340 SpecificSourcePackage $ pkg { srcpkgDescription =
341- srcpkgDescription & (\ f -> L. allCondTrees $ traverseCondTreeC f)
341+ -- New dependencies are added to the original ones found in the
342+ -- `targetBuildDepends` field.
343+ -- `traverseBuildInfos` is used in order to update _all_ the
344+ -- occurrences of the field `targetBuildDepends`. It ensures that
345+ -- fields depending on the latter are also consistently updated.
346+ srcpkgDescription & (L. traverseBuildInfos . L. targetBuildDepends)
342347 %~ (deps ++ )
343348 }
344349 addDeps spec = spec
Original file line number Diff line number Diff line change 1+ module Foo where
2+
3+ a :: Int
4+ a = 42
Original file line number Diff line number Diff line change 1+ # cabal clean
2+ # cabal repl
Original file line number Diff line number Diff line change 1+ # cabal clean
2+ # cabal repl
Original file line number Diff line number Diff line change 1+ # cabal clean
2+ # cabal repl
Original file line number Diff line number Diff line change 1+ packages : .
Original file line number Diff line number Diff line change 1+ import Test.Cabal.Prelude
2+
3+ -- Test “repl --build-depends”
4+ main = do
5+ testWithByteString " normal" []
6+ -- See https://github.com/haskell/cabal/issues/6859
7+ testWithByteString " allow-newer" [" --allow-newer" ]
8+ -- See https://github.com/haskell/cabal/issues/6859
9+ testWithByteString " allow-older" [" --allow-older" ]
10+ where
11+ testWithByteString label extraArgs = cabalTest' label $ do
12+ cabal' " clean" []
13+ res <- cabalWithStdin
14+ " repl"
15+ (" -v2" : " --build-depends" : " bytestring" : extraArgs)
16+ " import qualified Data.ByteString as BS"
17+ assertOutputContains " Ok, one module loaded." res
18+ -- Ensure we can load ‘bytestring’
19+ assertOutputDoesNotContain " Could not load" res
Original file line number Diff line number Diff line change 1+ cabal-version : 2.4
2+ name : pkg
3+ version : 0.1.0.0
4+ library
5+ exposed-modules : Foo
6+ build-depends : base
7+ default-language : Haskell2010
Original file line number Diff line number Diff line change 1+ synopsis: Fix repl discarding --build-depends
2+ packages: cabal-install
3+ prs: #8732
4+ issues: #6859 #7081
5+
6+ description: {
7+
8+ - Fix `repl` command discarding `--build-depends` argument when using
9+ `allow-newer` or `allow-older`.
10+ }
You can’t perform that action at this time.
0 commit comments