Skip to content

Commit

Permalink
restore rc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jul 27, 2017
1 parent 5d607c5 commit d515c5e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
12 changes: 10 additions & 2 deletions src/Paket.Core/Dependencies/PackageResolver.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 13 additions & 5 deletions tests/Paket.Tests/Resolver/ConflictGraphSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,12 @@ nuget My.Company.PackageC.Server rc"""
[<Test>]
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
Expand All @@ -176,9 +180,13 @@ nuget My.Company.PackageC.Server > 0.1"""
[<Test>]
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
Expand Down

0 comments on commit d515c5e

Please sign in to comment.