From f94e5d841ae0d68153d23e27c9fcfb17a5be28a5 Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Wed, 16 Dec 2015 00:22:31 -0600 Subject: [PATCH] (GH-507)(specs) Failing dependency version single tree NuGet should walk a dependency tree and find the most appropriate package by falling back down the dependency tree until it finds an appropriate version that is suitable for all dependency sets and then fail appropriately if no suitable version can be found. Unfortunately when you use a Dependency Version Behavior of Highest, NuGet just fails completely and refuses to work at all. I've been able to verify this as high as the latest version of NuGet package manager that is available with VS2013. I'm hopeful this is fixed in the v3.x of NuGet.Core. --- Scenarios.md | 24 +- .../scenarios/InstallScenarios.cs | 223 ++++++++++++++++++ 2 files changed, 246 insertions(+), 1 deletion(-) diff --git a/Scenarios.md b/Scenarios.md index b9b1af05b7..37ac118581 100644 --- a/Scenarios.md +++ b/Scenarios.md @@ -1,6 +1,6 @@ ## Chocolatey Usage Scenarios -### ChocolateyInstallCommand [ 30 Scenario(s), 254 Observation(s) ] +### ChocolateyInstallCommand [ 32 Scenario(s), 270 Observation(s) ] #### when force installing a package that depends on an unavailable newer version of an installed dependency forcing dependencies @@ -223,6 +223,18 @@ * should not have warning package result * should not install a package in the lib directory +#### when installing a package with a dependent package that also depdends on a less constrained but still valid dependency of the same package + + * [PENDING] should contain a message that everything installed successfully + * [PENDING] should have a successful package result + * [PENDING] should install a package in the lib directory + * [PENDING] should install the dependency in the lib directory + * [PENDING] should install the expected version of the constrained dependency + * [PENDING] should install the expected version of the dependency + * [PENDING] should install where install location reports + * [PENDING] should not have inconclusive package result + * [PENDING] should not have warning package result + #### when installing a package with config transforms * should add the insert value in the config due to XDT InsertIfMissing @@ -280,6 +292,16 @@ * [PENDING] should not upgrade the exact version dependency * [PENDING] should not upgrade the minimum version dependency +#### when installing a package with dependencies on an older version of a package than is already installed + + * [PENDING] should contain a message that it was unable to install any packages + * [PENDING] should have an error package result + * [PENDING] should not have a successful package result + * [PENDING] should not have inconclusive package result + * [PENDING] should not have warning package result + * [PENDING] should not install the conflicting package in the lib directory + * [PENDING] should not upgrade the exact version dependency + #### when installing a side by side package * config should match package result name diff --git a/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs b/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs index 5919ee0544..5c3cf32d63 100644 --- a/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/InstallScenarios.cs @@ -2667,6 +2667,229 @@ public void should_have_an_error_package_result() errorFound.ShouldBeTrue(); } + } + + [Concern(typeof(ChocolateyInstallCommand))] + public class when_installing_a_package_with_dependencies_on_an_older_version_of_a_package_than_is_already_installed : ScenariosBase + { + public override void Context() + { + base.Context(); + Configuration.PackageNames = Configuration.Input = "hasdependency"; + Scenario.add_packages_to_source_location(Configuration, "hasdependency.1.0.0*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "conflictingdependency.2.1.0*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isdependency.*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + Scenario.install_package(Configuration, "conflictingdependency", "2.1.0"); + } + + /* + Setup should have the following installed: + * conflictingdependency 2.1.0 + * isexactversiondependency 2.0.0 + * isdependency at least 2.0.0 + */ + + public override void Because() + { + Results = Service.install_run(Configuration); + } + + [Fact] + [Pending("NuGet does not deal with version conflicts - GH-116")] + public void should_not_install_the_conflicting_package_in_the_lib_directory() + { + var packageDir = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames); + + Directory.Exists(packageDir).ShouldBeFalse(); + } + + [Fact] + [Pending("NuGet does not deal with version conflicts - GH-116")] + public void should_not_upgrade_the_exact_version_dependency() + { + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg"); + var package = new OptimizedZipPackage(packageFile); + package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + } + + [Fact] + [Pending("NuGet does not deal with version conflicts - GH-116")] + public void should_contain_a_message_that_it_was_unable_to_install_any_packages() + { + bool expectedMessage = false; + foreach (var message in MockLogger.MessagesFor(LogLevel.Warn).or_empty_list_if_null()) + { + if (message.Contains("installed 0/3")) expectedMessage = true; + } + + expectedMessage.ShouldBeTrue(); + } + + [Fact] + [Pending("NuGet does not deal with version conflicts - GH-116")] + public void should_not_have_a_successful_package_result() + { + foreach (var packageResult in Results) + { + packageResult.Value.Success.ShouldBeFalse(); + } + } + + [Fact] + [Pending("NuGet does not deal with version conflicts - GH-116")] + public void should_not_have_inconclusive_package_result() + { + foreach (var packageResult in Results) + { + packageResult.Value.Inconclusive.ShouldBeFalse(); + } + } + + [Fact] + [Pending("NuGet does not deal with version conflicts - GH-116")] + public void should_not_have_warning_package_result() + { + foreach (var packageResult in Results) + { + packageResult.Value.Warning.ShouldBeFalse(); + } + } + + [Fact] + [Pending("NuGet does not deal with version conflicts - GH-116")] + public void should_have_an_error_package_result() + { + bool errorFound = false; + + foreach (var packageResult in Results) + { + foreach (var message in packageResult.Value.Messages) + { + if (message.MessageType == ResultType.Error) + { + errorFound = true; + } + } + } + + errorFound.ShouldBeTrue(); + } + } + + [Concern(typeof(ChocolateyInstallCommand))] + public class when_installing_a_package_with_a_dependent_package_that_also_depdends_on_a_less_constrained_but_still_valid_dependency_of_the_same_package : ScenariosBase + { + public override void Context() + { + base.Context(); + Configuration.PackageNames = Configuration.Input = "toplevelhasexactversiondependency"; + Scenario.add_packages_to_source_location(Configuration, "toplevelhasexactversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "childdependencywithlooserversiondependency*" + Constants.PackageExtension); + Scenario.add_packages_to_source_location(Configuration, "isexactversiondependency*" + Constants.PackageExtension); + } + + public override void Because() + { + //MockLogger.LogMessagesToConsole = true; + Results = Service.install_run(Configuration); + } + + /* + Because should result in the following installed: + * toplevelhasexactversiondependency 1.0.0 + * childdependencywithlooserversiondependency 1.0.0 + * isexactversiondependency 1.0.0 + */ + + [Fact] + [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] + public void should_install_where_install_location_reports() + { + foreach (var packageResult in Results) + { + Directory.Exists(packageResult.Value.InstallLocation).ShouldBeTrue(); + } + } + + [Fact] + [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] + public void should_install_a_package_in_the_lib_directory() + { + var packageDir = Path.Combine(Scenario.get_top_level(), "lib", Configuration.PackageNames); + + Directory.Exists(packageDir).ShouldBeTrue(); + } + + [Fact] + [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] + public void should_install_the_dependency_in_the_lib_directory() + { + var packageDir = Path.Combine(Scenario.get_top_level(), "lib", "childdependencywithlooserversiondependency"); + + Directory.Exists(packageDir).ShouldBeTrue(); + } + + [Fact] + [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] + public void should_install_the_expected_version_of_the_dependency() + { + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "childdependencywithlooserversiondependency", "childdependencywithlooserversiondependency.nupkg"); + var package = new OptimizedZipPackage(packageFile); + package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + } + + [Fact] + [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] + public void should_install_the_expected_version_of_the_constrained_dependency() + { + var packageFile = Path.Combine(Scenario.get_top_level(), "lib", "isexactversiondependency", "isexactversiondependency.nupkg"); + var package = new OptimizedZipPackage(packageFile); + package.Version.Version.to_string().ShouldEqual("1.0.0.0"); + } + + [Fact] + [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] + public void should_contain_a_message_that_everything_installed_successfully() + { + bool expectedMessage = false; + foreach (var message in MockLogger.MessagesFor(LogLevel.Warn).or_empty_list_if_null()) + { + if (message.Contains("3/3")) expectedMessage = true; + } + + expectedMessage.ShouldBeTrue(); + } + + [Fact] + [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] + public void should_have_a_successful_package_result() + { + foreach (var packageResult in Results) + { + packageResult.Value.Success.ShouldBeTrue(); + } + } + + [Fact] + [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] + public void should_not_have_inconclusive_package_result() + { + foreach (var packageResult in Results) + { + packageResult.Value.Inconclusive.ShouldBeFalse(); + } + } + + [Fact] + [Pending("NuGet does not handle version conflicts with highestversion dependency resolution - GH-507")] + public void should_not_have_warning_package_result() + { + foreach (var packageResult in Results) + { + packageResult.Value.Warning.ShouldBeFalse(); + } + } } [Concern(typeof(ChocolateyInstallCommand))]