Skip to content

Commit

Permalink
trying a fix for chocolatey#878
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Mosti committed Jul 28, 2016
1 parent ab78454 commit 2ea7df3
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
24 changes: 24 additions & 0 deletions src/chocolatey.tests.integration/scenarios/InstallScenarios.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,30 @@ public void should_not_have_warning_package_result()
packageResult.Value.Warning.ShouldBeFalse();
}
}

[Fact]
public void should_specify_config_file_is_beeing_used_in_message()
{
bool expectedMessage = false;
foreach (var message in MockLogger.MessagesFor(LogLevel.Info).or_empty_list_if_null())
{
if (message.Contains("Installing from config file:")) expectedMessage = true;
}

expectedMessage.ShouldBeTrue();
}

[Fact]
public void should_print_out_package_from_config_file_in_message()
{
bool expectedMessage = false;
foreach (var message in MockLogger.MessagesFor(LogLevel.Info).or_empty_list_if_null())
{
if (message.Contains("installpackage")) expectedMessage = true;
}

expectedMessage.ShouldBeTrue();
}
}

[Concern(typeof(ChocolateyInstallCommand))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ private string capture_arguments(ChocolateyConfiguration config, PackageResult p

public ConcurrentDictionary<string, PackageResult> install_run(ChocolateyConfiguration config)
{
this.Log().Info(@"Installing the following packages:");
this.Log().Info(is_packages_config_file(config) ? @"Installing from config file:" : @"Installing the following packages:");
this.Log().Info(ChocolateyLoggers.Important, @"{0}".format_with(config.PackageNames));

var packageInstalls = new ConcurrentDictionary<string, PackageResult>();
Expand All @@ -446,6 +446,7 @@ public ConcurrentDictionary<string, PackageResult> install_run(ChocolateyConfigu
{
action = (packageResult) => handle_package_result(packageResult, packageConfig, CommandNameType.install);
}

var results = perform_source_runner_function(packageConfig, r => r.install_run(packageConfig, action));

foreach (var result in results)
Expand Down Expand Up @@ -524,13 +525,18 @@ private IEnumerable<ChocolateyConfiguration> set_config_from_package_names_and_p

foreach (var packageConfig in get_packages_from_config(packageConfigFile, config, packageInstalls).or_empty_list_if_null())
{
yield return packageConfig;
yield return packageConfig;
}
}

yield return config;
}

private bool is_packages_config_file(ChocolateyConfiguration config)
{
return config.PackageNames.Split(new[] {ApplicationParameters.PackageNamesSeparator}, StringSplitOptions.RemoveEmptyEntries).or_empty_list_if_null().Any(p => p.EndsWith(".config"));
}

private IEnumerable<ChocolateyConfiguration> get_packages_from_config(string packageConfigFile, ChocolateyConfiguration config, ConcurrentDictionary<string, PackageResult> packageInstalls)
{
IList<ChocolateyConfiguration> packageConfigs = new List<ChocolateyConfiguration>();
Expand All @@ -546,6 +552,7 @@ private IEnumerable<ChocolateyConfiguration> get_packages_from_config(string pac
}

var settings = _xmlService.deserialize<PackagesConfigFileSettings>(_fileSystem.get_full_path(packageConfigFile));
this.Log().Info(@"Installing the following packages:");
foreach (var pkgSettings in settings.Packages.or_empty_list_if_null())
{
if (!pkgSettings.Disabled)
Expand All @@ -560,6 +567,7 @@ private IEnumerable<ChocolateyConfiguration> get_packages_from_config(string pac
if (pkgSettings.AllowMultipleVersions) packageConfig.AllowMultipleVersions = true;
if (pkgSettings.IgnoreDependencies) packageConfig.IgnoreDependencies = true;

this.Log().Info(ChocolateyLoggers.Important, @"{0}".format_with(packageConfig.PackageNames));
packageConfigs.Add(packageConfig);
}
}
Expand Down

0 comments on commit 2ea7df3

Please sign in to comment.