-
Notifications
You must be signed in to change notification settings - Fork 905
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
(#798, #2787, #1185) Add or update tests for side by side installs, pin during install/upgrade, hook scripts #2823
Conversation
3c73b17
to
4431f83
Compare
Task linked: ENGTASKS-1480 Chocolatey CLI |
4431f83
to
e38e974
Compare
d26f68d
to
60aefc7
Compare
60aefc7
to
ff3e5fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just ran the tests you had changed, and a few of them are currently failing in test kitchen.
Would need to fix up these tests before we can merge the changes into the repository.
Context uninstall hooks with flag:
[-] Exits with expected value (-1) 421ms (418ms|4ms)
Expected -1, because Chocolatey v1.2.0-PullReques-20220924-ff3e5fda
Uninstalling the following packages:
upgradepackage
pre-beforemodify-all.ps1 hook ran for upgradepackage 1.1.0
pre-beforemodify-upgradepackage.ps1 hook ran for upgradepackage 1.1.0
upgradepackage 1.1.0 Before Modification
post-beforemodify-all.ps1 hook ran for upgradepackage 1.1.0
post-beforemodify-upgradepackage.ps1 hook ran for upgradepackage 1.1.0
upgradepackage v1.1.0
pre-uninstall-all.ps1 hook ran for upgradepackage 1.1.0
pre-uninstall-upgradepackage.ps1 hook ran for upgradepackage 1.1.0
upgradepackage 1.1.0 Uninstalled
post-uninstall-all.ps1 hook ran for upgradepackage 1.1.0
post-uninstall-upgradepackage.ps1 hook ran for upgradepackage 1.1.0
Skipping auto uninstaller - No registry snapshot.
[NuGet] Skipping 'upgradepackage\tools\console.exe.config' it was modified.
upgradepackage has been successfully uninstalled.
Chocolatey uninstalled 1/1 packages.
See the log for details (C:\Users\Administrator\AppData\Local\Temp\ChocolateyTests\snapshots\8f2b5c8e-e96a-4435-8cdf-06b9b3ef67ce\install\logs\chocolatey.log)., but got 0.
at $Output.ExitCode | Should -Be $ExitCode -Because $Output.String, C:\Users\vagrant\AppData\Local\Temp\verifier\suites\chocolatey-tests\features\Hooks.Tests.ps1:51
at <ScriptBlock>, C:\Users\vagrant\AppData\Local\Temp\verifier\suites\chocolatey-tests\features\Hooks.Tests.ps1:51
[+] Should execute hooks (True) 14ms (13ms|1ms)
Context uninstall hooks with flag: --skip-powershell
[-] Exits with expected value (-1) 10ms (7ms|2ms)
Expected -1, because Chocolatey v1.2.0-PullReques-20220924-ff3e5fda
Uninstalling the following packages:
upgradepackage
upgradepackage v1.1.0
Skipping auto uninstaller - No registry snapshot.
[NuGet] Skipping 'upgradepackage\tools\console.exe.config' it was modified.
upgradepackage has been successfully uninstalled.
Chocolatey uninstalled 1/1 packages.
See the log for details (C:\Users\Administrator\AppData\Local\Temp\ChocolateyTests\snapshots\c39395d6-cebd-4e88-91fa-0e46af87270b\install\logs\chocolatey.log)., but got 0.
at $Output.ExitCode | Should -Be $ExitCode -Because $Output.String, C:\Users\vagrant\AppData\Local\Temp\verifier\suites\chocolatey-tests\features\Hooks.Tests.ps1:51
at <ScriptBlock>, C:\Users\vagrant\AppData\Local\Temp\verifier\suites\chocolatey-tests\features\Hooks.Tests.ps1:51
[+] Should execute hooks (False) 9ms (8ms|1ms)
Context uninstall hooks with flag: --skip-hooks
[-] Exits with expected value (-1) 8ms (5ms|2ms)
Expected -1, because Chocolatey v1.2.0-PullReques-20220924-ff3e5fda
Uninstalling the following packages:
upgradepackage
upgradepackage 1.1.0 Before Modification
upgradepackage v1.1.0
upgradepackage 1.1.0 Uninstalled
Skipping auto uninstaller - No registry snapshot.
[NuGet] Skipping 'upgradepackage\tools\console.exe.config' it was modified.
upgradepackage has been successfully uninstalled.
Chocolatey uninstalled 1/1 packages.
See the log for details (C:\Users\Administrator\AppData\Local\Temp\ChocolateyTests\snapshots\c25ff219-d293-47e3-bbfc-f1464bf3af55\install\logs\chocolatey.log)., but got 0.
at $Output.ExitCode | Should -Be $ExitCode -Because $Output.String, C:\Users\vagrant\AppData\Local\Temp\verifier\suites\chocolatey-tests\features\Hooks.Tests.ps1:51
at <ScriptBlock>, C:\Users\vagrant\AppData\Local\Temp\verifier\suites\chocolatey-tests\features\Hooks.Tests.ps1:51
[+] Should execute hooks (False) 14ms (13ms|1ms)
Context upgrade hooks with flag:
[+] Exits with expected value (-1) 9ms (3ms|6ms)
[+] Should execute hooks (True) 13ms (12ms|1ms)
Context upgrade hooks with flag: --skip-powershell
[-] Exits with expected value (-1) 6ms (4ms|2ms)
Expected -1, because Chocolatey v1.2.0-PullReques-20220924-ff3e5fda
Upgrading the following packages:
upgradepackage
By upgrading, you accept licenses for the packages.
You have upgradepackage v1.0.0 installed. Version 1.1.0 is available based on your source(s).
[NuGet] Skipping 'upgradepackage\tools\console.exe.config' it was modified.
upgradepackage v1.1.0
upgradepackage package files upgrade completed. Performing other installation steps.
Transforming 'console.exe.config' with the data from 'console.exe.config.install.xdt'
ShimGen has successfully created a shim for console.exe
ShimGen has successfully created a gui shim for graphical.exe
The upgrade of upgradepackage was successful.
Software installed to 'C:\Users\Administrator\AppData\Local\Temp\ChocolateyTests\snapshots\3ee22d6b-ce0d-41c3-9d78-926a1a7b2312\install\lib\upgradepackage'
Chocolatey upgraded 1/1 packages.
See the log for details (C:\Users\Administrator\AppData\Local\Temp\ChocolateyTests\snapshots\3ee22d6b-ce0d-41c3-9d78-926a1a7b2312\install\logs\chocolatey.log)., but got 0.
at $Output.ExitCode | Should -Be $ExitCode -Because $Output.String, C:\Users\vagrant\AppData\Local\Temp\verifier\suites\chocolatey-tests\features\Hooks.Tests.ps1:51
at <ScriptBlock>, C:\Users\vagrant\AppData\Local\Temp\verifier\suites\chocolatey-tests\features\Hooks.Tests.ps1:51
[+] Should execute hooks (False) 7ms (6ms|1ms)
The info tests enable a proxy that prevents the side by side tests from actually working correctly. This restores the Snapshot so we have a fresh Chocolatey installation to test against.
Add tests that we are pinning packages when during upgrade and install when done with the `--pin` parameter.
Add tests that hook scripts execute in scenarios where they're expected to run.
Move the command tests into a new commands directory, with features in a new features directory. This should make it easier and clearer which tests are specific to what aspects of Chocolatey.
With the upgrade package used in the tests, it currently exits with -1 even though it is successful. Instead of blindly accepting 0 and -1 for all the tests, be explicit about which one we expect so we can catch changes to this exit code.
ff3e5fd
to
794bf67
Compare
I've fixed up those exit codes @AdmiringWorm so they should all pass now. It seems I forgot which packages were being used where and when to expect 0 and -1 😅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@corbob thank you for getting this added and fixed up 👍 |
Description Of Changes
Add or update tests for side by side installations being deprecated, pin package during install and upgrade, and hook scripts.
Motivation and Context
Testing
choco install
commands to ensure that there are no warnings about$env:ChocolateyInstall/hooks
not being found.Change Types Made
Related Issue
Related to:
Change Checklist