From d515c5e8a5a4c1828352e28da8b81081a1e88389 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Thu, 27 Jul 2017 17:30:31 +0200 Subject: [PATCH] restore rc tests --- src/Paket.Core/Dependencies/PackageResolver.fs | 12 ++++++++++-- .../Paket.Tests/Resolver/ConflictGraphSpecs.fs | 18 +++++++++++++----- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/Paket.Core/Dependencies/PackageResolver.fs b/src/Paket.Core/Dependencies/PackageResolver.fs index 963e6b3809..794c4c56eb 100644 --- a/src/Paket.Core/Dependencies/PackageResolver.fs +++ b/src/Paket.Core/Dependencies/PackageResolver.fs @@ -525,13 +525,21 @@ let private getCompatibleVersions let compatibleVersions, globalOverride = if currentRequirement.VersionRequirement.Range.IsGlobalOverride then compatibleVersions, true - elif Seq.isEmpty compatibleVersions && currentRequirement.TransitivePrereleases then + elif Seq.isEmpty compatibleVersions && currentRequirement.TransitivePrereleases && not (currentRequirement.Parent.IsRootRequirement()) then Seq.filter (isInRange (fun r -> r.IncludingPrereleases(PreReleaseStatus.All))) availableVersions |> Seq.cache, globalOverride elif Seq.isEmpty compatibleVersions then + + let prereleaseStatus (r:PackageRequirement) = + if r.Parent.IsRootRequirement() && r.VersionRequirement <> VersionRequirement.AllReleases then + r.VersionRequirement.PreReleases + else + PreReleaseStatus.All + let available = availableVersions |> Seq.toList let allPrereleases = available |> List.filter (fun (v,_) -> v.PreRelease <> None) = available + let prereleases = List.filter (isInRange (fun r -> r.IncludingPrereleases(prereleaseStatus r))) available if allPrereleases then - Seq.ofList available, globalOverride + Seq.ofList prereleases, globalOverride else compatibleVersions, globalOverride else diff --git a/tests/Paket.Tests/Resolver/ConflictGraphSpecs.fs b/tests/Paket.Tests/Resolver/ConflictGraphSpecs.fs index c4cd3e66f6..becb849d27 100644 --- a/tests/Paket.Tests/Resolver/ConflictGraphSpecs.fs +++ b/tests/Paket.Tests/Resolver/ConflictGraphSpecs.fs @@ -161,8 +161,12 @@ nuget My.Company.PackageC.Server rc""" [] let ``should resolve simple config with servers with RC requirement``() = let cfg = DependenciesFile.FromSource(configWithServersWithRCRequirement) - ResolveWithGraph(cfg,noSha1,VersionsFromGraphAsSeq graphWithServers, PackageDetailsFromGraph graphWithServers).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() - |> ignore + try + ResolveWithGraph(cfg,noSha1,VersionsFromGraphAsSeq graphWithServers, PackageDetailsFromGraph graphWithServers).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() + |> ignore + failwith "expected exception" + with + | exn when exn.Message.Contains " package My.Company.PackageA.Server" -> () let configWithServersWithVersionRequirement = """ source https://www.nuget.org/api/v2 @@ -176,9 +180,13 @@ nuget My.Company.PackageC.Server > 0.1""" [] let ``should resolve simple config with servers with version requirement``() = let cfg = DependenciesFile.FromSource(configWithServersWithVersionRequirement) - ResolveWithGraph(cfg,noSha1,VersionsFromGraphAsSeq graphWithServers, PackageDetailsFromGraph graphWithServers).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() - |> ignore - + try + ResolveWithGraph(cfg,noSha1,VersionsFromGraphAsSeq graphWithServers, PackageDetailsFromGraph graphWithServers).[Constants.MainDependencyGroup].ResolvedPackages.GetModelOrFail() + |> ignore + failwith "expected exception" + with + | exn when exn.Message.Contains " package My.Company.PackageA.Server" -> () + let configWithServersWithoutVersionRequirement = """ source https://www.nuget.org/api/v2