Skip to content

style: align test scaffolding with canonical PSMTplt#18

Open
tablackburn wants to merge 1 commit into
mainfrom
style/align-test-scaffolding-with-template
Open

style: align test scaffolding with canonical PSMTplt#18
tablackburn wants to merge 1 commit into
mainfrom
style/align-test-scaffolding-with-template

Conversation

@tablackburn
Copy link
Copy Markdown
Owner

@tablackburn tablackburn commented May 12, 2026

Summary

Applies the three style rules from PowerShellModuleTemplate#23 to the Help/Meta/MetaFixers test files this repo inherited from the template, plus two adjacent fixes the cross-repo audit surfaced:

File Change
tests/Help.tests.ps1 Named-parameter cleanup on Split-Path, Join-Path, Test-Path, Get-Module. Restores the PR #23-era multi-paramset mandatory-skip block on the 'Has correct [mandatory] value' It (this repo was carrying the pre-#23 version). Fixes a stale $parameterNames reference in the last Context block.
tests/Meta.tests.ps1 Named parameters on Get-TextFilesList -Root, Test-FileUnicode -FileInfo, Get-Content -Path, Select-String -Pattern.
tests/MetaFixers.psm1 [ValidateNotNull()] on $FileInfo in ConvertTo-UTF8 and ConvertTo-SpaceIndentation; [ValidateNotNullOrEmpty()] on $Root in Get-TextFilesList and Get-UnicodeFilesList. Plus Test-FileUnicode $_Test-FileUnicode -FileInfo $_ inside Get-UnicodeFilesList.

Why

PR #23 brought the template's first-party test files into compliance with the three rules in instructions/powershell.instructions.md. The scaffolds this repo inherited were carrying the pre-#23 shape; this PR closes the gap.

Two adjacent fixes bundled in per the cross-repo audit:

  1. Multi-paramset mandatory-skip block — the pre-#23 'Has correct [mandatory] value' It didn't handle parameters whose IsMandatory status varies across parameter sets (a common pattern with -ParameterSetName cmdlets). The PR #23-era block skips those with a clear reason. Behavior is unchanged for parameters with consistent IsMandatory; previously-flaky tests on multi-paramset parameters will now skip cleanly.
  2. $parameterNames$commandParameterNames — stale reference in the last Context block was silently passing nothing. JsmOps and YouTubeMusicPS already have the correct form. The fix activates a Context block that was previously a no-op.

Out of scope

tests/Manifest.tests.ps1 is the older Module Dependency variant (no Test-VersionConstraint helper, no $isTemplate skip, -Child typo on Join-Path) — deferred to a separate uplift PR that brings the manifest test up to current canonical.

Test plan

  • ./build.ps1 runs the same assertion count as before (or more — the previously-no-op Context block will now execute its It for each $helpParameterNames entry)
  • CI passes on Linux / macOS / Windows runners
  • PSScriptAnalyzer remains clean

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests

    • Enhanced test infrastructure with improved parameter validation and file handling in test utilities.
  • Chores

    • Updated internal test setup and configuration to use explicit named parameters and improved path composition logic.

Review Change Stack

Apply the three style rules from PowerShellModuleTemplate#23 to the
Help/Meta/MetaFixers test files this repo inherited from the template:

- Named parameters on multi-arg cmdlet calls (Split-Path, Join-Path,
  Test-Path, Get-Module, Get-Content, Select-String, Get-TextFilesList,
  Test-FileUnicode)
- ValidateNotNull / ValidateNotNullOrEmpty validators on mandatory
  param entries in tests/MetaFixers.psm1
- Test-FileUnicode call inside Get-UnicodeFilesList now uses named
  -FileInfo parameter

Also restores the PR #23-era multi-paramset mandatory-skip block on
the 'Has correct [mandatory] value' It in Help.tests.ps1 (this repo
was carrying the pre-#23 version that doesn't handle parameters with
varying IsMandatory status across parameter sets), and fixes a stale
$parameterNames reference in the last Context block (should be
$commandParameterNames). Both bundled in per the cross-repo audit.

tests/Manifest.tests.ps1 is the older Module Dependency variant
(no Test-VersionConstraint helper, -Child typo on Join-Path) and is
deferred to a separate uplift PR.

Behavior is unchanged for parameters with consistent IsMandatory across
sets; previously-failing-or-flaky tests on multi-paramset parameters
will now skip with a clear reason.
Copilot AI review requested due to automatic review settings May 12, 2026 04:25
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ceb89ee7-e1e4-4954-8ee9-fd26547ded8f

📥 Commits

Reviewing files that changed from the base of the PR and between a0611f7 and 025e417.

📒 Files selected for processing (3)
  • tests/Help.tests.ps1
  • tests/Meta.tests.ps1
  • tests/MetaFixers.psm1

📝 Walkthrough

Walkthrough

This PR updates test infrastructure files to enforce parameter validation on helper cmdlets and align function calls throughout test files to use named parameters consistently, improving code robustness and maintainability. Build environment path handling and help parameter validation logic are also refined.

Changes

Test Infrastructure Parameter Validation and Named Parameter Alignment

Layer / File(s) Summary
Test Helper Parameter Validation
tests/MetaFixers.psm1
ConvertTo-UTF8 and ConvertTo-SpaceIndentation gain [ValidateNotNull()] on FileInfo, while Get-TextFilesList and Get-UnicodeFilesList gain [ValidateNotNullOrEmpty()] on Root.
Named Parameter Alignment in Test Calls
tests/Meta.tests.ps1, tests/Help.tests.ps1
Function calls update from positional to named parameters: Get-TextFilesList -Root, Test-FileUnicode -FileInfo, Get-Content -Path -Raw, Get-Module -Name.
Help Test Setup and Validation Refinements
tests/Help.tests.ps1
Build environment path composition uses Split-Path -Path ... -Parent and Join-Path. Help mandatory-value assertions now account for parameter-set variance and use lowercased comparison. Parameter presence check targets $commandParameterNames.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Possibly related PRs

  • tablackburn/ReScenePS#11: Both PRs modify tests/Help.tests.ps1 to bootstrap BuildHelpers using Set-BuildEnvironment with Split-Path -Parent $PSScriptRoot.

Poem

🐰 With parameters named and helpers validated true,
Test paths are clearer, now named through and through.
No more positional guessing, just clarity bright,
The test suite now marches with parameter delight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'style: align test scaffolding with canonical PSMTplt' accurately and specifically describes the main change: applying style rules to test files to align them with the template.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch style/align-test-scaffolding-with-template

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

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 pull request aligns the repository’s inherited test scaffolding and meta-fixer utilities with the canonical PowerShellModuleTemplate conventions (notably named-parameter usage) and includes two audit-driven correctness fixes in the help tests and meta fixers.

Changes:

  • Standardize named-parameter usage across Help.tests.ps1 and Meta.tests.ps1 (e.g., Split-Path -Path ... -Parent, Get-Content -Path, Select-String -Pattern, Get-Module -Name).
  • Reinstate/introduce a skip path in help tests for parameters whose mandatory status differs across parameter sets.
  • Strengthen parameter validation in MetaFixers.psm1 and ensure Test-FileUnicode is invoked with -FileInfo.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/Help.tests.ps1 Style cleanup + parameter-set-aware mandatory check; fixes a stale variable reference.
tests/Meta.tests.ps1 Style cleanup to use named parameters for consistency.
tests/MetaFixers.psm1 Add validation attributes and align helper calls with named parameters.

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

Comment thread tests/Help.tests.ps1
Comment on lines 244 to +248
Context 'Test <_> help parameter help for <commandName>' -Foreach $helpParameterNames {

# Shouldn't find extra parameters in help
It 'finds help parameter in code: <_>' {
$_ -in $parameterNames | Should -Be $true
$_ -in $commandParameterNames | Should -Be $true
@codecov
Copy link
Copy Markdown

codecov Bot commented May 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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.

2 participants