style: align test scaffolding with canonical PSMTplt#18
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 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.
|
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)
📝 WalkthroughWalkthroughThis 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. ChangesTest Infrastructure Parameter Validation and Named Parameter Alignment
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related issues
Possibly related PRs
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
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.ps1andMeta.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.psm1and ensureTest-FileUnicodeis 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.
| 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 Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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:
tests/Help.tests.ps1Split-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$parameterNamesreference in the lastContextblock.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. 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:
'Has correct [mandatory] value'Itdidn't handle parameters whoseIsMandatorystatus varies across parameter sets (a common pattern with-ParameterSetNamecmdlets). The PR #23-era block skips those with a clear reason. Behavior is unchanged for parameters with consistentIsMandatory; previously-flaky tests on multi-paramset parameters will now skip cleanly.$parameterNames→$commandParameterNames— stale reference in the lastContextblock 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.ps1is the older Module Dependency variant (noTest-VersionConstrainthelper, no$isTemplateskip,-Childtypo onJoin-Path) — 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