style: align test scaffolding with canonical PSMTplt#55
Conversation
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 fixes a stale $parameterNames reference in the last Context block of Help.tests.ps1 (should be $commandParameterNames). Bug 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.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe pull request hardens test infrastructure by adding parameter validation to helper functions, updating test callers to use explicit named parameters, and refining build environment initialization in the Help test file. ChangesTest Infrastructure Robustness
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
Aligns this repository’s inherited test scaffolding with the canonical PowerShellModuleTemplate style rules (named parameters for multi-arg cmdlets, mandatory-parameter validators), and fixes a stale variable reference that previously made part of the help-parameter verification effectively a no-op.
Changes:
- Standardize named-parameter usage across Help/Meta tests (e.g.,
Split-Path,Join-Path,Get-Module,Get-Content,Select-String). - Add parameter validators in
tests/MetaFixers.psm1for mandatory parameters ([ValidateNotNull()],[ValidateNotNullOrEmpty()]). - Fix
$parameterNames→$commandParameterNamesin the help tests so the “extra help parameters” check actually evaluates.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/Help.tests.ps1 | Uses named parameters for several cmdlet calls and fixes a stale variable reference so the relevant Context block is no longer a no-op. |
| tests/Meta.tests.ps1 | Applies named parameters to calls into MetaFixers and standard cmdlets (Get-Content, Select-String). |
| tests/MetaFixers.psm1 | Adds validators for mandatory params and updates Test-FileUnicode invocation to use the explicit -FileInfo parameter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Applies the three style rules from PowerShellModuleTemplate#23 to the Help/Meta/MetaFixers test files this repo inherited from the template:
tests/Help.tests.ps1Split-Path,Join-Path,Test-Path,Get-Module(3 call sites ofSplit-Path -Parent; 2 each ofJoin-PathandGet-Module; 1Test-Path). Plus fixes a stale$parameterNamesreference in the lastContextblock — should be$commandParameterNames.tests/Meta.tests.ps1Get-TextFilesList -Root,Test-FileUnicode -FileInfo,Get-Content -Path,Select-String -Pattern.tests/MetaFixers.psm1[ValidateNotNull()]on$FileInfoinConvertTo-UTF8andConvertTo-SpaceIndentation;[ValidateNotNullOrEmpty()]on$RootinGet-TextFilesListandGet-UnicodeFilesList. PlusTest-FileUnicode $_→Test-FileUnicode -FileInfo $_insideGet-UnicodeFilesList.Why
PR #23 brought the template's first-party test files into compliance with the three rules in
instructions/powershell.instructions.md(quoted string literals, named multi-arg cmdlet calls, mandatory-param validators). The scaffolds this repo inherited were carrying the pre-#23 shape; this PR closes the gap.The
$parameterNames→$commandParameterNamesfix bundled into this PR is an adjacent bug found during the cross-repo audit (the stale reference was silently passing nothing — the test as written was effectively a no-op). JsmOps and YouTubeMusicPS already have the correct form.Behavior is unchanged for the style sweep; the
$parameterNamesfix activates a Context block that was previously a no-op.Out of scope
tests/Manifest.tests.ps1is the older Module Dependency variant (noTest-VersionConstrainthelper, no$isTemplateskip,-Childtypo onJoin-Pathat line 163) — deferred to a separate uplift PR that brings the manifest test up to current canonical.Test plan
./build.ps1runs the same assertion count as before (or more — the previously-no-opContextblock will now execute itsItfor each$helpParameterNamesentry)🤖 Generated with Claude Code
Summary by CodeRabbit
Tests
Chores