Skip to content

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

Merged
daxian-dbw merged 1 commit intoPowerShell:release/v7.6from
daxian-dbw:backport/release/v7.6/26602-2e7765eef
Jan 21, 2026
Merged

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

Conversation

@daxian-dbw
Copy link
Member

Backport of #26602 to release/v7.6

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)

Customer Impact

  • Customer reported
  • Found internally

Test infrastructure issue where $PSDefaultParameterValues leaks between test files caused tests that should run on Linux to be skipped. This only affects internal testing, not customer functionality.

Regression

REQUIRED: Check exactly one box.

  • Yes
  • No

This is not a regression.

Testing

The fix has been tested in the original PR. The changes restore proper state isolation in test files, ensuring that $PSDefaultParameterValues modifications don't leak to subsequent tests. This can be verified by running the affected test files on Linux and confirming that tests which should run on Linux are no longer skipped.

Risk

REQUIRED: Check exactly one box.

  • High
  • Medium
  • Low

The changes only affect test isolation and don't modify any product code. The fixes ensure proper cleanup of test state, which cannot cause product regressions. The changes have already been tested and merged in master.

…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 January 20, 2026 22:23
@daxian-dbw daxian-dbw added the CL-Test Indicates that a PR should be marked as a test change in the Change Log label Jan 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

This PR backports a test infrastructure fix from master (#26602) to the release/v7.6 branch. The fix addresses $PSDefaultParameterValues state leakage between test files that caused tests intended to run on Linux to be incorrectly skipped.

Changes:

  • Fixed imbalanced Push-DefaultParameterValueStack/Pop-DefaultParameterValueStack calls in 2 test files
  • Replaced .Remove() pattern with proper clone/restore pattern in 4 test files to ensure proper state isolation

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 tests are skipped
test/powershell/engine/Remoting/SessionOption.Tests.ps1 Changed from .Remove() to clone/restore pattern for proper state isolation
test/powershell/engine/Remoting/RemoteSession.Basic.Tests.ps1 Removed duplicate Pop-DefaultParameterValueStack call that had no matching Push
test/powershell/engine/ETS/CimAdapter.Tests.ps1 Changed from .Remove() to clone/restore pattern for proper state isolation
test/powershell/Modules/Microsoft.PowerShell.Security/AclCmdlets.Tests.ps1 Changed from .Remove() to clone/restore pattern for proper state isolation
test/powershell/Modules/Microsoft.PowerShell.Management/Rename-Computer.Tests.ps1 Changed from .Remove() to clone/restore pattern for proper state isolation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@daxian-dbw daxian-dbw merged commit 86475e9 into PowerShell:release/v7.6 Jan 21, 2026
67 of 75 checks passed
@daxian-dbw daxian-dbw deleted the backport/release/v7.6/26602-2e7765eef branch January 21, 2026 19:52
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