From 34fed222f45749e7197a4f475558e4e10fd06694 Mon Sep 17 00:00:00 2001 From: Cory Knox Date: Wed, 28 Sep 2022 19:32:11 -0700 Subject: [PATCH] (#886) Update packages.config install logging Update the debug logging when a packages.config file is being used to output the start and end of the configuration on independent lines. This allows us to update the test to get these start and end points and not play guessing games with how long we think the output should be. Updating this test allows Chocolatey Licensed Extension to be included and the tests still pass. --- .../services/ChocolateyPackageService.cs | 2 +- tests/chocolatey-tests/commands/choco-install.Tests.ps1 | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 5933f324ab..09ae129488 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -793,7 +793,7 @@ private IEnumerable get_packages_from_config(string pac this.Log().Info(ChocolateyLoggers.Important, @"{0}".format_with(packageConfig.PackageNames)); packageConfigs.Add(packageConfig); - this.Log().Debug(() => "Package Configuration: {0}".format_with(packageConfig.ToString())); + this.Log().Debug(() => "Package Configuration Start:{0}{1}{0}Package Configuration End".format_with(System.Environment.NewLine, packageConfig.ToString())); } } diff --git a/tests/chocolatey-tests/commands/choco-install.Tests.ps1 b/tests/chocolatey-tests/commands/choco-install.Tests.ps1 index 79825f92ab..daf7a34e19 100644 --- a/tests/chocolatey-tests/commands/choco-install.Tests.ps1 +++ b/tests/chocolatey-tests/commands/choco-install.Tests.ps1 @@ -247,9 +247,11 @@ Describe "choco install" -Tag Chocolatey, InstallCommand { $Output = Invoke-Choco install $env:CHOCOLATEY_TEST_PACKAGES_PATH\alloptions.packages.config --confirm --verbose --debug # This is based on two observations: The addition explicitly outputs that it's the Package Configuration. - # The configuration output is also about 80 lines. - $StartofPackageConfiguration = [array]::IndexOf($Output.Lines, "Package Configuration: CommandName='install'|") - $PackageConfigurationOutput = $Output.Lines[$StartofPackageConfiguration..($StartofPackageConfiguration+80)] -join [Environment]::NewLine + # The configuration output is about 80 lines. + $StartOfPackageConfiguration = [array]::IndexOf($Output.Lines, "Package Configuration Start:") + $EndOfPackageConfiguration = [array]::IndexOf($Output.Lines, "Package Configuration End") + + $PackageConfigurationOutput = $Output.Lines[$StartofPackageConfiguration..$EndOfPackageConfiguration] -join [Environment]::NewLine } # We are explicitly passing in a bad username and password here.