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

(#2851) fix license validation output #2857

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

corbob
Copy link
Member

@corbob corbob commented Oct 14, 2022

Description Of Changes

Update the logic used in LicenseValidation class to correctly detect when regular output is desired and when it's not.

Motivation and Context

When there are certain license conditions, Chocolatey would report things to standard output even if the command issues was requesting to limit output.

Testing

  1. Put a file in the license directory and ran choco list --local-only --limit-output
  2. Then ran choco list --local-only --limitoutput
  3. Then ran choco list --local-only -r
  4. Noted that there is some warnings and errors about missing directories (I followed these as far as I could, at least one is generated by a System provided library, and unlikely that we can suppress)
  5. When the lib directory is there (which it is on a standard Chocolatey install), no errors are output.
  6. Set an empty file as license/chocolatey.license.xml. Noted that limit output prevented the message about the license being invalid

This is currently a draft PR as I intend to add some Pester tests to verify that no extraneous output occurs when limit output is requested.

Change Types Made

  • Bug fix (non-breaking change)
  • Feature / Enhancement (non-breaking change)
  • Breaking change (fix or feature that could cause existing functionality to change)
  • PowerShell code changes.

Related Issue

Fixes #2851

Change Checklist

  • Requires a change to the documentation
  • Documentation has been updated
  • Tests to cover my changes, have been added
  • All new and existing tests passed.
  • PowerShell v2 compatibility checked.

.editorconfig file says all files should be CRLF. When editing the
recipe.cake with .editorconfig support, vscode wants to change the line
endings every time the file is saved. As there's no reason to keep the
file LF only, it seems reasonable to normalize the line endings before
making any other changes.
Chocolatey.Cake.Recipe version 0.17.0 included support for building from
a branch that starts with a number. Bumping to this version allows us to
work with a branch name that starts with numbers without needing to jump
through any hoops.
The LicenseValidation logging logic was only checking for `-v` or
`--version` as the first arguments. This completely ignored `-r`,
`--limit-output`, and `--limitoutput`. Additionally, a few places
weren't suppressing output when limit output was used. This change
correctly detects if regular output is desired, and if it is then it
marks the output accordingly, otherwise it outputs to the log file only.
@corbob
Copy link
Member Author

corbob commented Oct 14, 2022

Question regarding some tests for this: I checked out the add_headers branch I have, and ran the headers test after creating a dummy license file. This then failed any headers tests that expected headers because LicenseValidation was outputting. Are we comfortable with this being a sufficient test for this PR? If we are, then I will rebase this on add_headers and stack these PRs so that this one bases off of that one and then I can update the Pester tests for that one.

2022-10-14_13-55-15

@corbob corbob marked this pull request as ready for review October 31, 2022 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

License Validation outputs some errors and warnings when limit-output enabled.
1 participant