Fix $PSDefaultParameterValues leak causing tests to skip unexpectedly (#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).
This commit is contained in:
Copilot
2025-12-12 09:26:46 +05:00
committed by GitHub
parent 06ffbaeb44
commit 2e7765eef1
6 changed files with 10 additions and 6 deletions
@@ -3,6 +3,7 @@
Describe "Acl cmdlets are available and operate properly" -Tag CI {
Context "Windows ACL test" {
BeforeAll {
$originalDefaultParameterValues = $PSDefaultParameterValues.Clone()
$PSDefaultParameterValues["It:Skip"] = -not $IsWindows
}
@@ -103,7 +104,7 @@ Describe "Acl cmdlets are available and operate properly" -Tag CI {
}
AfterAll {
$PSDefaultParameterValues.Remove("It:Skip")
$global:PSDefaultParameterValues = $originalDefaultParameterValues
}
}
}