Commit 53cfe17d authored by Mikhail Glushenkov's avatar Mikhail Glushenkov
Browse files

Fix '--allow-newer' bugs caught by tests.

* Fix parsing of '--allow-newer=foo --allow-newer=bar'.
* Fix './Setup configure --allow-newer --enable-{tests, benchmarks}'.
parent cd61c58d
......@@ -310,7 +310,13 @@ findDistPrefOrDefault = findDistPref defaultDistPref
-- Returns the @.setup-config@ file.
configure :: (GenericPackageDescription, HookedBuildInfo)
-> ConfigFlags -> IO LocalBuildInfo
configure (pkg_descr0, pbi) cfg = do
configure (pkg_descr0', pbi) cfg = do
let pkg_descr0 =
-- Ignore '--allow-newer' when we're given '--exact-configuration'.
if fromFlagOrDefault False (configExactConfiguration cfg)
then pkg_descr0'
else relaxPackageDeps (configAllowNewer cfg) pkg_descr0'
setupMessage verbosity "Configuring" (packageId pkg_descr0)
checkDeprecatedFlags verbosity cfg
......@@ -827,15 +833,8 @@ configureFinalizedPackage verbosity cfg
flaggedBenchmarks = map (\(n, bm) ->
(n, mapTreeData enableBenchmark bm))
(condBenchmarks pkg_descr0)
pkg_descr0''' =
-- Ignore '--allow-newer' when we're given '--exact-configuration'.
if fromFlagOrDefault False (configExactConfiguration cfg)
then pkg_descr0
else relaxPackageDeps
(fromFlagOrDefault AllowNewerNone $ configAllowNewer cfg)
pkg_descr0
pkg_descr0'' = pkg_descr0''' { condTestSuites = flaggedTests
, condBenchmarks = flaggedBenchmarks }
pkg_descr0'' = pkg_descr0 { condTestSuites = flaggedTests
, condBenchmarks = flaggedBenchmarks }
(pkg_descr0', flags) <-
case finalizePackageDescription
......
......@@ -299,12 +299,11 @@ allowNewerParser = ReadE $ \s ->
where
pkgsParser = Parse.sepBy1 parse (Parse.char ',')
allowNewerPrinter :: Flag AllowNewer -> [Maybe String]
allowNewerPrinter (Flag AllowNewerNone) = [Just "False"]
allowNewerPrinter (Flag AllowNewerAll) = [Just "True"]
allowNewerPrinter (Flag (AllowNewerSome pkgs)) =
allowNewerPrinter :: AllowNewer -> [Maybe String]
allowNewerPrinter AllowNewerNone = []
allowNewerPrinter AllowNewerAll = [Nothing]
allowNewerPrinter (AllowNewerSome pkgs) =
[Just . intercalate "," . map display $ pkgs]
allowNewerPrinter NoFlag = []
-- | Flags to @configure@ command.
--
......@@ -374,7 +373,8 @@ data ConfigFlags = ConfigFlags {
-- ^Halt and show an error message indicating an error in flag assignment
configRelocatable :: Flag Bool, -- ^ Enable relocatable package built
configDebugInfo :: Flag DebugInfoLevel, -- ^ Emit debug info.
configAllowNewer :: Flag AllowNewer -- ^
configAllowNewer :: AllowNewer -- ^ Ignore upper bounds on all or some
-- dependencies.
}
deriving (Generic, Read, Show)
......@@ -421,7 +421,7 @@ defaultConfigFlags progConf = emptyConfigFlags {
configFlagError = NoFlag,
configRelocatable = Flag False,
configDebugInfo = Flag NoDebugInfo,
configAllowNewer = NoFlag
configAllowNewer = AllowNewerNone
}
configureCommand :: ProgramConfiguration -> CommandUI ConfigFlags
......@@ -661,9 +661,7 @@ configureOptions showOrParseArgs =
,option [] ["allow-newer"]
("Ignore upper bounds in all dependencies or DEPS")
configAllowNewer (\v flags -> flags { configAllowNewer = v})
(optArg "DEPS"
(fmap Flag allowNewerParser) (Flag AllowNewerAll)
allowNewerPrinter)
(optArg "DEPS" allowNewerParser AllowNewerAll allowNewerPrinter)
,option "" ["exact-configuration"]
"All direct dependencies and flags are provided on the command line."
......@@ -882,12 +880,9 @@ instance Semigroup ConfigFlags where
configFlagError = combine configFlagError,
configRelocatable = combine configRelocatable,
configDebugInfo = combine configDebugInfo,
configAllowNewer = combineAllowNewer (configAllowNewer a)
(configAllowNewer b)
configAllowNewer = combine configAllowNewer
}
where combine field = field a `mappend` field b
combineAllowNewer (Flag fa) (Flag fb) = (Flag $ fa `mappend` fb)
combineAllowNewer fa fb = fa `mappend` fb
-- ------------------------------------------------------------
-- * Copy flags
......
......@@ -19,6 +19,8 @@
work-around for #2398)
* Library support for multi-instance package DBs (#2948).
* Improved the './Setup configure' solver (#3082, #3076).
* The '--allow-newer' option can be now used with './Setup
configure' (#3163).
1.22.0.0 Johan Tibell <johan.tibell@gmail.com> January 2015
* Support GHC 7.10.
......
......@@ -204,6 +204,11 @@ instance Semigroup SavedConfig where
combine' field subfield =
(subfield . field $ a) `mappend` (subfield . field $ b)
combineMonoid :: Monoid mon => (SavedConfig -> flags) -> (flags -> mon)
-> mon
combineMonoid field subfield =
(subfield . field $ a) `mappend` (subfield . field $ b)
lastNonEmpty' :: (SavedConfig -> flags) -> (flags -> [a]) -> [a]
lastNonEmpty' field subfield =
let a' = subfield . field $ a
......@@ -325,7 +330,8 @@ instance Semigroup SavedConfig where
configExactConfiguration = combine configExactConfiguration,
configFlagError = combine configFlagError,
configRelocatable = combine configRelocatable,
configAllowNewer = combine configAllowNewer
configAllowNewer = combineMonoid savedConfigureFlags
configAllowNewer
}
where
combine = combine' savedConfigureFlags
......
......@@ -63,7 +63,7 @@ import Distribution.Version
import Distribution.Simple.Utils as Utils
( warn, notice, info, debug, die )
import Distribution.Simple.Setup
( AllowNewer(..), isAllowNewer )
( isAllowNewer )
import Distribution.System
( Platform )
import Distribution.Text ( display )
......@@ -86,8 +86,7 @@ chooseCabalVersion configFlags maybeVersion =
where
-- Cabal < 1.19.2 doesn't support '--exact-configuration' which is needed
-- for '--allow-newer' to work.
allowNewer = fromFlagOrDefault False $
fmap isAllowNewer (configAllowNewer configFlags)
allowNewer = isAllowNewer (configAllowNewer configFlags)
defaultVersionRange = if allowNewer
then orLaterVersion (Version [1,19,2] [])
......@@ -289,8 +288,7 @@ planLocalPackage verbosity comp platform configFlags configExFlags
fromFlagOrDefault False $ configBenchmarks configFlags
resolverParams =
removeUpperBounds (fromFlagOrDefault AllowNewerNone $
configAllowNewer configFlags)
removeUpperBounds (configAllowNewer configFlags)
. addPreferences
-- preferences from the config file or command line
......
......@@ -417,7 +417,7 @@ planPackages comp platform mSandboxPkgInfo solver
maxBackjumps = fromFlag (installMaxBackjumps installFlags)
upgradeDeps = fromFlag (installUpgradeDeps installFlags)
onlyDeps = fromFlag (installOnlyDeps installFlags)
allowNewer = fromFlag (configAllowNewer configFlags)
allowNewer = (configAllowNewer configFlags)
-- | Remove the provided targets from the install plan.
pruneInstallPlan :: Package targetpkg
......
......@@ -370,7 +370,7 @@ filterConfigureFlags flags cabalLibVersion
configConstraints = [],
-- Passing '--allow-newer' to Setup.hs is unnecessary, we use
-- '--exact-configuration' instead.
configAllowNewer = NoFlag
configAllowNewer = Cabal.AllowNewerNone
}
-- Cabal < 1.23 doesn't know about '--profiling-detail'.
......
......@@ -42,6 +42,8 @@
default location or as specified by --config-file (#2553).
* The man page for 'cabal-install' is now automatically generated
(#2877).
* The '--allow-newer' option now works as expected when specified
multiple times (#2588).
1.22.0.0 Johan Tibell <johan.tibell@gmail.com> January 2015
* New command: user-config (#2159).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment