Fix HelpSystem tests for invariant culture#27547
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates the HelpSystem Pester tests to be resilient when running under the invariant culture by temporarily switching to en-US so localized assertions remain stable.
Changes:
- Adds
BeforeAll/AfterAllhooks to capture and restoreCurrentCulture/CurrentUICulture. - Forces
en-USculture when the current culture or UI culture is invariant (LCID 127) for the “full view by default” tests.
| if ($script:helpFullViewCultureState.CurrentCulture.LCID -eq 127 -or | ||
| $script:helpFullViewCultureState.CurrentUICulture.LCID -eq 127) { |
There was a problem hiding this comment.
Addressed in 9c863a1f7: the invariant culture comparison now uses [System.Globalization.CultureInfo]::InvariantCulture.LCID instead of the hard-coded 127.
| $enUSCulture = [System.Globalization.CultureInfo]::GetCultureInfo('en-US') | ||
| [System.Globalization.CultureInfo]::CurrentCulture = $enUSCulture | ||
| [System.Globalization.CultureInfo]::CurrentUICulture = $enUSCulture | ||
| $script:helpFullViewCultureState.Changed = $true |
There was a problem hiding this comment.
Addressed in 9c863a1f7: the culture fallback is now scoped with BeforeEach/AfterEach, and it only replaces the culture slots that are actually invariant before restoring them after each test. Checks run: git diff --check; script parse via [scriptblock]::Create(...). I also attempted Start-PSPester -Path test\powershell\engine\Help\HelpSystem.Tests.ps1; this local run failed in existing help-system environment cases, including IOException: The handle is invalid and missing about_test* help content.
PR Summary
Make the
help function uses full view by defaultCI tests switch toen-USwhen the process culture or UI culture is invariant, then restore the original cultures after the describe block.PR Context
Fixes #27532.
These tests assert against the
PARAMETERSsection from the bundled full help content. On Linux environments where the culture resolves to invariant culture (LCID 127), the localized help content is not selected, so those assertions can fail even though the full-view behavior is not broken. This mirrors the invariant-culture guard already used by the UpdatableHelp tests.Validation
git diff --check -- test/powershell/engine/Help/HelpSystem.Tests.ps1test/powershell/engine/Help/HelpSystem.Tests.ps1withSystem.Management.Automation.Language.Parseren-USand restores the saved culturesStart-PSBuild -Clean -PSModuleRestore -UseNuGetOrgStart-PSPester -Path test/powershell/engine/Help/HelpSystem.Tests.ps1 -Tag CI -UseNuGetOrg(local run reached the targeted file but the desktop host hit existing non-interactive Help test failures: invalid console handle inhelpcalls plus unrelated help-file lookup misses)PR Checklist
masterbranch.