Skip to content

[release/v7.4] Fix $PSDefaultParameterValues leak causing tests to skip unexpectedly#26869

Merged
adityapatwardhan merged 1 commit intoPowerShell:release/v7.4from
TravisEz13:backport/release/v7.4/26602-2e7765eef
Feb 20, 2026
Merged

[release/v7.4] Fix $PSDefaultParameterValues leak causing tests to skip unexpectedly#26869
adityapatwardhan merged 1 commit intoPowerShell:release/v7.4from
TravisEz13:backport/release/v7.4/26602-2e7765eef

Conversation

@TravisEz13
Copy link
Member

Backport of #26602 to release/v7.4

Triggered by @TravisEz13 on behalf of @app/copilot-swe-agent

Original CL Label: CL-Test

/cc @PowerShell/powershell-maintainers

Impact

REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.

Tooling Impact

  • Required tooling change
  • Optional tooling change (include reasoning)

Fixes test isolation to prevent $PSDefaultParameterValues["It:Skip"] from leaking across tests on Linux.

Customer Impact

  • Customer reported
  • Found internally

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

Not run locally; original PR describes reproduction and fixes.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Changes are limited to test scripts.

…PowerShell#26602)

This fixes test isolation issues where six test files were leaking $PSDefaultParameterValues["It:Skip"] settings to subsequent tests, causing widespread test skipping on Linux. The fixes address two distinct patterns: using .Remove() which doesn't restore the original state (4 files), and imbalanced Push-DefaultParameterValueStack/Pop-DefaultParameterValueStack calls (2 files).
Copilot AI review requested due to automatic review settings February 20, 2026 22:14
@TravisEz13 TravisEz13 added the CL-Test Indicates that a PR should be marked as a test change in the Change Log label Feb 20, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Backport to release/v7.4 that fixes Pester test isolation issues where $PSDefaultParameterValues changes (notably It:Skip) leaked across test files and caused unexpected skips on Linux CI runs.

Changes:

  • Restore $PSDefaultParameterValues from a cloned snapshot in AfterAll/finally blocks instead of using .Remove(...).
  • Fix an imbalanced Push-DefaultParameterValueStack/Pop-DefaultParameterValueStack pair by ensuring Pop-DefaultParameterValueStack is called when a skip path is taken.
  • Remove an extra/unmatched Pop-DefaultParameterValueStack in a remoting test to prevent stack underflow/leaks.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
test/powershell/engine/Security/FileSignature.Tests.ps1 Ensures Pop-DefaultParameterValueStack executes when the suite is skipped, preventing leaked default parameters.
test/powershell/engine/Remoting/SessionOption.Tests.ps1 Clones and restores $PSDefaultParameterValues in try/finally to avoid persistent it:skip settings.
test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 Removes an unmatched Pop-DefaultParameterValueStack; keeps pop only for the skip path.
test/powershell/engine/ETS/CimAdapter.Tests.ps1 Restores full $PSDefaultParameterValues state after setting it:pending on non-Windows.
test/powershell/Modules/Microsoft.PowerShell.Security/AclCmdlets.Tests.ps1 Restores full $PSDefaultParameterValues state after setting It:Skip for non-Windows.
test/powershell/Modules/Microsoft.PowerShell.Management/Rename-Computer.Tests.ps1 Restores full $PSDefaultParameterValues state after setting it:skip for non-Windows.

@adityapatwardhan adityapatwardhan enabled auto-merge (squash) February 20, 2026 22:27
@adityapatwardhan adityapatwardhan merged commit f9cd7d9 into PowerShell:release/v7.4 Feb 20, 2026
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CL-Test Indicates that a PR should be marked as a test change in the Change Log

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants