Skip to content

style: align test scaffolding with canonical PSMTplt#9

Merged
tablackburn merged 1 commit into
mainfrom
style/align-test-scaffolding-with-template
May 12, 2026
Merged

style: align test scaffolding with canonical PSMTplt#9
tablackburn merged 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 test files this repo inherited from the template:

File Change
tests/Help.tests.ps1 Named-parameter cleanup on Split-Path, Join-Path, Test-Path, Get-Module (3 call sites of Split-Path -Parent; 2 each of Join-Path and Get-Module; 1 Test-Path).
tests/Manifest.tests.ps1 Same named-parameter cleanup (paths block appears twice — once in BeforeDiscovery, once in BeforeAll). Plus one bareword -ErrorAction Stop-ErrorAction 'Stop', and Get-Content $changelogPathGet-Content -Path $changelogPath.
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 (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 so the templated test layer matches canonical.

Behavior is unchanged. Same Pester assertions run, just with hardened call sites.

Test plan

  • ./build.ps1 runs the same assertion count as before
  • CI passes on Linux / macOS / Windows runners
  • PSScriptAnalyzer remains clean

Out of scope

The 6 mandatory-string-param validators in tests/ManifestHelpers.psm1 shipped already in PR #8 (2026-05-11); the Split-SemVerString validator shipped earlier in PR #7. The remaining template-side drift (stale .PARAMETER "Must not be null" text on Compare-SemVerPrerelease, now-redundant IsNullOrWhiteSpace guards on Test-VersionConstraint) is tracked in PowerShellModuleTemplate#30 and will propagate from the template source.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests

    • Improved test infrastructure with stricter environment-based path resolution and enhanced parameter validation in test utilities.
  • Chores

    • Updated test setup logic and file discovery patterns for consistency across test suites.

Review Change Stack

Apply the three style rules from PowerShellModuleTemplate#23 to the 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)
- Quoted string literals where they were left bareword
  (one -ErrorAction Stop -> -ErrorAction 'Stop')
- ValidateNotNull / ValidateNotNullOrEmpty validators on mandatory param
  entries in tests/MetaFixers.psm1

Tests/MetaFixers.psm1 was also missing the named -FileInfo parameter on
the Test-FileUnicode call inside Get-UnicodeFilesList; aligned with
canonical.

Behavior is unchanged; this is the first-party-files compliance work
PR #23 brought to the template, applied here.
Copilot AI review requested due to automatic review settings May 12, 2026 03:49
@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: 59d0c4e0-0105-4581-a3ee-5aadf34f08ee

📥 Commits

Reviewing files that changed from the base of the PR and between baa8b71 and 6c7ea95.

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

📝 Walkthrough

Walkthrough

Test files and helper module apply parameter validation attributes, standardize path derivation patterns using named parameters, and improve robustness of manifest and file discovery workflows across test setup phases.

Changes

Test Infrastructure Hardening

Layer / File(s) Summary
Parameter validation and named parameter usage in MetaFixers
tests/MetaFixers.psm1
ConvertTo-UTF8, ConvertTo-SpaceIndentation, Get-TextFilesList, and Get-UnicodeFilesList now include [ValidateNotNull()] or [ValidateNotNullOrEmpty()] attributes; Get-UnicodeFilesList uses named -FileInfo parameter in pipeline instead of positional argument.
Meta.tests.ps1 text file discovery with named parameters
tests/Meta.tests.ps1
Text file discovery now calls Get-TextFilesList with named -Root parameter; tab detection uses backtick-escaped pattern ("`t") for correct literal tab matching.
Help.tests.ps1 consistent path derivation
tests/Help.tests.ps1
Set-BuildEnvironment and project-root computation standardized to Split-Path -Path $PSScriptRoot -Parent in both BeforeDiscovery and BeforeAll; build-output and manifest paths derived via Join-Path; custom-types discovery adds conditional Test-Path check.
Manifest.tests.ps1 consistent path derivation and robust manifest parsing
tests/Manifest.tests.ps1
Set-BuildEnvironment and project-root computation apply same Split-Path -Path $PSScriptRoot -Parent pattern in both BeforeDiscovery and BeforeAll; manifest import now uses -ErrorAction 'Stop' and explicit Get-Content for changelog version extraction.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

Poem

🐰 A rabbit's work in tests so fine,
With validation guards and paths align,
Named parameters dance in proper form,
Each layer checked, each pattern norm—
Infrastructure strengthened, robust and true! ✨

🚥 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 PR title 'style: align test scaffolding with canonical PSMTplt' clearly and accurately summarizes the main change: applying style rules to align test files with the PowerShell Module Template standard.
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 PR aligns the repository’s inherited PowerShell test scaffolding with the canonical PowerShellModuleTemplate style rules (named multi-arg cmdlet parameters, quoted string literals where required, and mandatory parameter validators), without changing test behavior.

Changes:

  • Standardized multi-argument cmdlet calls to use named parameters across Pester tests (e.g., Split-Path, Join-Path, Test-Path, Get-Module, Get-Content, Select-String).
  • Added mandatory-parameter validation attributes in tests/MetaFixers.psm1 for key parameters.
  • Normalized a few PowerShell literal/parameter usages (e.g., -ErrorAction 'Stop', Get-Content -Path ...).

Reviewed changes

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

File Description
tests/Help.tests.ps1 Converts several cmdlet calls to named-parameter form for consistency with template style rules.
tests/Manifest.tests.ps1 Applies named-parameter cleanup in both discovery and execution setup blocks; normalizes a couple of parameter/literal usages.
tests/Meta.tests.ps1 Updates helper calls to use named parameters (Get-TextFilesList, Test-FileUnicode, Get-Content, Select-String).
tests/MetaFixers.psm1 Adds validators to mandatory parameters and standardizes a helper invocation to named parameter form.

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

Comment thread tests/MetaFixers.psm1
@tablackburn tablackburn merged commit 78c201e into main May 12, 2026
15 checks passed
@tablackburn tablackburn deleted the style/align-test-scaffolding-with-template branch May 12, 2026 04:20
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