Skip to content

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

Merged
daxian-dbw merged 1 commit intoPowerShell:release/v7.5from
daxian-dbw:backport/release/v7.5/26602-2e7765eef
Feb 14, 2026
Merged

[release/v7.5] Fix $PSDefaultParameterValues leak causing tests to skip unexpectedly#26823
daxian-dbw merged 1 commit intoPowerShell:release/v7.5from
daxian-dbw:backport/release/v7.5/26602-2e7765eef

Conversation

@daxian-dbw
Copy link
Member

Backport of #26602 to release/v7.5

Triggered by @daxian-dbw 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 $PSDefaultParameterValues leaks in test files causing unexpected test skipping

Customer Impact

  • Customer reported
  • Found internally

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

Fixes issue #26601. Tests now properly isolate $PSDefaultParameterValues changes. Validated in 7.6 release.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

Fixes test infrastructure issue where tests were incorrectly skipped on Linux. Changes only affect test files. Successfully backported to 7.6 branch.

…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).
@daxian-dbw daxian-dbw added the CL-Test Indicates that a PR should be marked as a test change in the Change Log label Feb 13, 2026
Copilot AI review requested due to automatic review settings February 13, 2026 23:55
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

This PR is a backport of #26602 to the release/v7.5 branch, fixing $PSDefaultParameterValues leaks in six test files that were causing tests to skip unexpectedly on Linux. The leaks occurred when test files modified $PSDefaultParameterValues["It:Skip"] but failed to properly restore the original state, causing the modification to persist and affect subsequent tests.

Changes:

  • Fixed 4 test files that used .Remove() by switching to the Clone/restore pattern
  • Fixed 2 test files with imbalanced Push-DefaultParameterValueStack/Pop-DefaultParameterValueStack calls
  • All changes ensure proper test isolation by restoring $PSDefaultParameterValues to its original state

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 Added missing Pop-DefaultParameterValueStack call in AfterAll when shouldSkip is true
test/powershell/engine/Remoting/SessionOption.Tests.ps1 Replaced .Remove() with Clone/restore pattern to properly isolate $PSDefaultParameterValues changes
test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 Removed unconditional Pop that had no matching Push, fixing imbalanced Push/Pop calls
test/powershell/engine/ETS/CimAdapter.Tests.ps1 Replaced .Remove() with Clone/restore pattern and fixed typo (it:pending vs It:Skip)
test/powershell/Modules/Microsoft.PowerShell.Security/AclCmdlets.Tests.ps1 Replaced .Remove() with Clone/restore pattern to properly isolate $PSDefaultParameterValues changes
test/powershell/Modules/Microsoft.PowerShell.Management/Rename-Computer.Tests.ps1 Replaced .Remove() with Clone/restore pattern to properly isolate $PSDefaultParameterValues changes

@daxian-dbw daxian-dbw merged commit 54b881d into PowerShell:release/v7.5 Feb 14, 2026
22 checks passed
@daxian-dbw daxian-dbw deleted the backport/release/v7.5/26602-2e7765eef branch February 14, 2026 00:30
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.

3 participants