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

implement V3 according to feedback given in #2700 #2708

Merged
merged 3 commits into from
Sep 2, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 17 additions & 1 deletion integrationtests/Paket.IntegrationTests/NuGetV3Specs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,20 @@ let ``#1387 update package in v3``() =
update "i001387-nugetv3" |> ignore
let lockFile = LockFile.LoadFrom(Path.Combine(scenarioTempPath "i001387-nugetv3","paket.lock"))
lockFile.Groups.[Constants.MainDependencyGroup].Resolution.[PackageName "Bender"].Version
|> shouldEqual (SemVer.Parse "3.0.29.0")
|> shouldEqual (SemVer.Parse "3.0.29.0")

[<Test>]
let ``#2700-1 v3 works properly``() =
paketEx true "update" "i002700-1" |> ignore
let lockFile = LockFile.LoadFrom(Path.Combine(scenarioTempPath "i002700-1","paket.lock"))
let mainGroup = lockFile.Groups.[Constants.MainDependencyGroup]
mainGroup.Resolution.[PackageName "Microsoft.CSharp"].Source.Url
|> shouldEqual "https://www.myget.org/F/dotnet-core-svc/api/v3/index.json"

[<Test>]
let ``#2700-2 v2 is not upgraded to v3``() =
updateEx true "i002700-2" |> ignore
let lockFile = LockFile.LoadFrom(Path.Combine(scenarioTempPath "i002700-2","paket.lock"))
let mainGroup = lockFile.Groups.[Constants.MainDependencyGroup]
mainGroup.Resolution.[PackageName "Microsoft.CSharp"].Source.Url
|> shouldEqual "https://www.myget.org/F/dotnet-core-svc"
68 changes: 47 additions & 21 deletions integrationtests/Paket.IntegrationTests/TestHelper.fs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ let prepare scenario =
for file in Directory.GetFiles(scenarioPath, (sprintf "*.%stemplate" ext), SearchOption.AllDirectories) do
File.Move(file, Path.ChangeExtension(file, ext))

let directPaketInPath command scenarioPath =
type PaketMsg =
{ IsError : bool; Message : string }
static member isError ({ IsError = e}:PaketMsg) = e
static member getMessage ({ Message = msg }:PaketMsg) = msg

let directPaketInPathEx command scenarioPath =
#if INTERACTIVE
let result =
ExecProcessWithLambdas (fun info ->
Expand All @@ -81,12 +86,14 @@ let directPaketInPath command scenarioPath =
false
(printfn "%s")
(printfn "%s")
string result
let res = new ResizeArray()
res.Add (string result)
res
#else
Environment.SetEnvironmentVariable("PAKET_DETAILED_ERRORS", "true")
printfn "%s> paket %s" scenarioPath command
let perfMessages = ResizeArray()
let msgs = ResizeArray()
let msgs = ResizeArray<PaketMsg>()
let mutable perfMessagesStarted = false
let addAndPrint isError msg =
if not isError then
Expand All @@ -95,7 +102,7 @@ let directPaketInPath command scenarioPath =
elif perfMessagesStarted then
perfMessages.Add(msg)

msgs.Add((isError, msg))
msgs.Add({ IsError = isError; Message = msg})

let result =
try
Expand All @@ -114,12 +121,12 @@ let directPaketInPath command scenarioPath =
else
printfn "ExecProcessWithLambdas failed. Output was: "

for isError, msg in msgs do
for { IsError = isError; Message = msg } in msgs do
printfn "%s%s" (if isError then "ERR: " else "") msg
reraise()
// Only throw after the result <> 0 check because the current test might check the argument parsing
// this is the only case where no performance is printed
let isUsageError = result <> 0 && msgs |> Seq.filter fst |> Seq.map snd |> Seq.exists (fun msg -> msg.Contains "USAGE:")
let isUsageError = result <> 0 && msgs |> Seq.filter PaketMsg.isError |> Seq.map PaketMsg.getMessage |> Seq.exists (fun msg -> msg.Contains "USAGE:")
if not isUsageError then
if perfMessages.Count = 0 then
failwith "No Performance messages recieved in test!"
Expand All @@ -128,47 +135,66 @@ let directPaketInPath command scenarioPath =
printfn "%s" msg

// always print stderr
for isError, msg in msgs do
if isError then
printfn "ERR: %s" msg
for msg in msgs do
if msg.IsError then
printfn "ERR: %s" msg.Message

if result <> 0 then
let errors = String.Join(Environment.NewLine,msgs |> Seq.filter fst |> Seq.map snd)
let errors = String.Join(Environment.NewLine,msgs |> Seq.filter PaketMsg.isError |> Seq.map PaketMsg.getMessage)
if String.IsNullOrWhiteSpace errors then
failwithf "The process exited with code %i" result
else
failwith errors


String.Join(Environment.NewLine,msgs |> Seq.map snd)
msgs
#endif
let private fromMessages msgs =
String.Join(Environment.NewLine,msgs |> Seq.map PaketMsg.getMessage)

let directPaketInPath command scenarioPath = directPaketInPathEx command scenarioPath |> fromMessages

let directPaket command scenario =
let directPaketEx command scenario =
partitionForTravis scenario
directPaketInPath command (scenarioTempPath scenario)
directPaketInPathEx command (scenarioTempPath scenario)

let paket command scenario =
let directPaket command scenario = directPaketEx command scenario |> fromMessages

let paketEx checkZeroWarn command scenario =
prepare scenario

directPaket command scenario
let msgs = directPaketEx command scenario
if checkZeroWarn then
msgs
|> Seq.filter PaketMsg.isError
|> Seq.toList
|> shouldEqual []
msgs

let update scenario =
let paket command scenario =
paketEx false command scenario |> fromMessages

let updateEx checkZeroWarn scenario =
#if INTERACTIVE
paket "update --verbose" scenario |> printfn "%s"
#else
paket "update" scenario |> ignore
paketEx checkZeroWarn "update" scenario |> ignore
#endif
LockFile.LoadFrom(Path.Combine(scenarioTempPath scenario,"paket.lock"))

let install scenario =
let update scenario =
updateEx false scenario

let installEx checkZeroWarn scenario =
#if INTERACTIVE
paket "install --verbose" scenario |> printfn "%s"
#else
paket "install" scenario |> ignore
paketEx checkZeroWarn "install" scenario |> ignore
#endif
LockFile.LoadFrom(Path.Combine(scenarioTempPath scenario,"paket.lock"))

let restore scenario = paket "restore" scenario |> ignore
let install scenario = installEx false scenario

let restore scenario = paketEx false "restore" scenario |> ignore

let updateShouldFindPackageConflict packageName scenario =
try
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source https://www.myget.org/F/dotnet-core-svc/api/v3/index.json

nuget Microsoft.CSharp prerelease
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
source https://www.myget.org/F/dotnet-core-svc

nuget Microsoft.CSharp prerelease
2 changes: 1 addition & 1 deletion src/Paket.Core/Dependencies/NuGet.fs
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ let GetVersions force alternativeProjectRoot root (sources, packageName:PackageN

return v2Feeds
| NuGetV3 source ->
let! versionsAPI = PackageSources.getNuGetV3Resource source AllVersionsAPI
let! versionsAPI = NuGetV3.getNuGetV3Resource source NuGetV3.AllVersionsAPI
let auth = source.Authentication |> Option.map toCredentials
return [ getVersionsCached "V3" tryNuGetV3 (nugetSource, auth, versionsAPI, packageName) ]
| LocalNuGet(path,Some _) ->
Expand Down
Loading