Skip to content

Fix WinPS adapter tests #1017

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

Merged
merged 11 commits into from
Aug 5, 2025
Merged

Conversation

SteveL-MSFT
Copy link
Member

@SteveL-MSFT SteveL-MSFT commented Jul 29, 2025

PR Summary

Pester 5.7.1 was crashing due to stdout leaking from BeforeAll. Fix is to redirect the native command output to $null. In addition, modified test to be skipped if not Windows or not elevated. Removed nested use of BeforeDiscovery within tests.

After resolving the crash, apparently many tests have been broken for some time but wasn't reported since Pester crashes before it writes the output file so CI thinks they all passed:

  • Split WinPS cache and non-cache tests into separate files since there's some interaction with messing with the cache and paths that cause subsequent non-cache specific tests to fail
  • Add more tracing to help isolate issues including emitting current working directory for resource since on my system dsc kept using the store installed version instead of the debug built one
  • In BeforeAll section, isolate PATH and PSModulePath to use specific resources so that ones already on the system don't get used
  • Fix PSCredential handling in WinPS adapter where classbased returns type as PSCredential instead of [PSCredential]
  • Change PSCredential test to use a class based resource instead of mocks for end-to-end validation
  • Add trap in adapter so that any uncaught exceptions get traced
  • Fix issue where adapters weren't being added to internal resource list so on discovery, it finds older version of adapters
  • Fix test checking if [console] is available before using as in CI it's not available
  • Skip rebootPending tests if not Windows or elevated

@SteveL-MSFT SteveL-MSFT requested a review from tgauth July 29, 2025 20:20
@SteveL-MSFT SteveL-MSFT mentioned this pull request Jul 29, 2025
@SteveL-MSFT SteveL-MSFT marked this pull request as draft July 30, 2025 04:33
@SteveL-MSFT SteveL-MSFT changed the title Skip winps tests if not Windows or not elevated, redirect native output to $null Fix WinPS adapter tests Aug 5, 2025
Steve Lee (POWERSHELL HE/HIM) (from Dev Box) added 2 commits August 4, 2025 19:14
@SteveL-MSFT SteveL-MSFT marked this pull request as ready for review August 5, 2025 02:58
Steve Lee (POWERSHELL HE/HIM) (from Dev Box) added 2 commits August 4, 2025 20:03
@SteveL-MSFT SteveL-MSFT added this pull request to the merge queue Aug 5, 2025
Merged via the queue into PowerShell:main with commit 197064c Aug 5, 2025
4 checks passed
@SteveL-MSFT SteveL-MSFT deleted the winps-test-fix branch August 5, 2025 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants