Skip to content

Remove code specifically for PS 2.0-5.0#2735

Merged
nohwnd merged 1 commit into
mainfrom
fix/2510-remove-ps2-5-compat
Jun 23, 2026
Merged

Remove code specifically for PS 2.0-5.0#2735
nohwnd merged 1 commit into
mainfrom
fix/2510-remove-ps2-5-compat

Conversation

@nohwnd

@nohwnd nohwnd commented Jun 18, 2026

Copy link
Copy Markdown
Member

Remove version guards that are always true on PS 5.1+ (-ge 3, -ge 4, -ge 5) and their dead else branches. Tighten -ge 6\ to -ge 7\ since PS 6.x is EOL and Pester 6 supports PS 5.1 and PS 7+ only.

Changes across 6 files, removing ~80 lines of dead code:

  • Coverage.ps1: remove guards around DSC, class AST, and base constructor checks; remove pre-PS5 DSC keyword detection path
  • Mock.ps1: remove guards around PositionalBinding, parameter validation, alias repair; remove pre-PS5 \EscapeSingleQuotedStringContent\ fallback; remove pre-5.0.10586 reflection path for dynamic parameters
  • Output.ps1: simplify \HostSupportsOutput\ to always true
  • Pester.Types.ps1, TestDrive.ps1, Environment.ps1: -ge 6\ to -ge 7\

Fixes #2510

Remove version guards that are always true on PS 5.1+ (-ge 3, -ge 4,
-ge 5) and their dead else branches. This includes:

- Coverage.ps1: remove -ge 4/-ge 5 guards around DSC, class AST, and
  base constructor checks; remove pre-PS5 DSC keyword detection path
- Mock.ps1: remove -ge 3 guards around PositionalBinding, parameter
  validation, and alias repair; remove -ge 5 guard and pre-PS5 fallback
  in EscapeSingleQuotedStringContent; remove pre-5.0.10586 reflection
  path for dynamic parameters
- Output.ps1: simplify HostSupportsOutput to always true (PS 5+ uses
  InformationRecords)
- Pester.Types.ps1, TestDrive.ps1, Environment.ps1: tighten -ge 6 to
  -ge 7 (PS 6.x is EOL, Pester 6 supports PS 5.1 and PS 7+)

Fixes #2510

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nohwnd nohwnd merged commit e695984 into main Jun 23, 2026
13 checks passed
@nohwnd nohwnd deleted the fix/2510-remove-ps2-5-compat branch June 23, 2026 09:45
@nohwnd nohwnd added this to the 6.0.0 milestone Jun 23, 2026
nohwnd added a commit that referenced this pull request Jun 27, 2026
Three .Tests.ps1 suites were disabled with a top-level `return`, so
Invoke-Pester discovered them but ran zero tests.

- Environment.Tests.ps1: revived. Replace obsolete Mock-based fakes with
  the $SafeCommands override pattern (Pester internals call
  & $SafeCommands['Get-Variable'], which bypasses Mock) and align with the
  PS <7 => Windows threshold from #2735.
- Describe.Tests.ps1: remove the dead Pester v4 second half that exercised
  DescribeImpl / New-PesterState -Path / EnterTestGroup, all removed from src.
- TestsRunningInCleanRunspace.Tests.ps1: delete this Pester v4 Start-Job
  fossil after migrating its still-unique scenarios (output swallowing,
  It-without-scriptblock, graceful syntax-error handling) into modern
  in-process tests in Pester.RSpec.ts.ps1.
- SetupTeardown.Tests.ps1: update a stale comment that referenced the
  deleted suite.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove code specifically for PS 2.0-5.0

1 participant