test: align Manifest test with canonical template (dependency version checks + ManifestHelpers)#22
Conversation
Bring tests/Manifest.tests.ps1 up to the current PowerShellModuleTemplate
shape and add tests/ManifestHelpers.psm1 (copied verbatim) for SemVer-aware
version-constraint checks. Replaces the single-version Module Dependency
context with the canonical five-test version that validates the manifest's
RequiredModules against the dependency file via Test-VersionConstraint
(ModuleVersion/RequiredVersion/MaximumVersion -> LessOrEqual/Equal/
GreaterOrEqual), with clear skips for plain-string references and
missing/empty versions. Adds $manifestRawData, and carries over the
template-only $isTemplate skip plus the skipped 'Git tagging' Describe for
fidelity.
ReScenePS adaptations:
- Reads runtime.depend.psd1 (this repo's renamed requirements file) instead
of requirements.psd1.
- Preserves the psake Set-BuildEnvironment bootstrap (repo-wide isolation
pattern), corrected to the scoped named-parameter rule.
- Preserves the foreach changelog parse over the template's
ForEach-Object { ... break } (break is unreliable in ForEach-Object).
Deferred follow-up to #18. Build + Pester pass locally: 786 passed,
0 failed, 23 skipped.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Warning Review limit reached
More reviews will be available in 24 minutes and 41 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
✨ 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR aligns the manifest tests with the newer template-style dependency validation flow and adds a helper module for SemVer-aware version constraint checks.
Changes:
- Adds
ManifestHelpers.psm1with SemVer comparison and constraint validation helpers. - Updates
Manifest.tests.ps1bootstrap/path handling and imports raw manifest data. - Replaces the older dependency version check with per-version-key validation against
runtime.depend.psd1.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
tests/ManifestHelpers.psm1 |
Adds helper functions for SemVer-aware dependency version comparisons. |
tests/Manifest.tests.ps1 |
Updates manifest tests to validate dependency metadata and version constraints against runtime.depend.psd1. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
… foreach
Replace the foreach-over-Get-Content changelog-version parse with Select-String,
which returns the first matching line's named capture group directly — no loop and
no break. The foreach existed only to avoid the canonical template's unreliable
`ForEach-Object { ... break }`; Select-String removes the need for either form.
Mirrors the upstream fix in tablackburn/PowerShellModuleTemplate#37.
Build + Pester pass locally: 786 passed, 0 failed, 23 skipped.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
Resolving the
An explicit Resolving these threads as not applicable. |
…ak in ForEach-Object (#37) * fix(tests): parse changelog version with Select-String instead of break in ForEach-Object The BeforeAll changelog-version parse in tests/Manifest.tests.ps1 used `Get-Content $changelogPath | ForEach-Object { ... break }`. `break` inside ForEach-Object is unreliable: a pipeline is not a loop, so `break` targets an enclosing loop if one exists, or otherwise terminates the block unexpectedly, rather than cleanly stopping at the first match. Replace it with Select-String, which returns the first matching line's named capture group directly — no loop and no break. Behavior is unchanged (still resolves to the topmost `## [Version]` entry). Surfaced while aligning a downstream module's Manifest test (tablackburn/ReScenePS#22). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(tests): guard changelog version parse against no match Capture the Select-String MatchInfo before indexing so a missing or malformed changelog heading leaves $changelogVersion as $null and fails the assertion cleanly, instead of throwing "Cannot index into a null array" in BeforeAll. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
Brings
tests/Manifest.tests.ps1up to the current canonical PowerShellModuleTemplate shape and adds the helper module it depends on. This is the deferred follow-up to #18, which scoped out the manifest test as the "older Module Dependency variant."New file
tests/ManifestHelpers.psm1— copied verbatim from the template. ProvidesTest-VersionConstraint(and itsSplit-SemVerString/Compare-SemVerPrerelease/Test-VersionComparisoninternals) for SemVer 2.0.0-aware version-constraint checks, including prerelease precedence.Module Dependency context, uplifted
The single-version "Module Dependency" context is replaced with the canonical five-test version that validates the manifest's
RequiredModulesagainst the dependency manifest:<dep> exists in runtime.depend.psd1<dep> uses at least one version key(ModuleVersion/RequiredVersion/MaximumVersion)<dep> has a matching required version(RequiredVersion→Equal)<dep> has a maximum version >=(MaximumVersion→GreaterOrEqual)<dep> has a minimum version <=(ModuleVersion→LessOrEqual)Plain-string references, duplicate entries, and missing/empty versions are handled with clear skips/throws. Adds
$manifestRawData(Import-PowerShellDataFileof the built manifest) so the raw version keys are inspectable.For fidelity with the canonical source, the template-only
$isTemplateskip guard on "Changelog and manifest versions are the same" and the-SkippedDescribe 'Git tagging'block are carried over verbatim (both are inert in a consumer module but keep future template syncs clean).ReScenePS-specific adaptations
runtime.depend.psd1is read instead of the template'srequirements.psd1(this repo renamed the file in 0.2.3). ReScenePS's@{ ModuleName = 'SrrDBAutomationToolkit'; ModuleVersion = '0.4.0' }maps onto the canonical logic via the hashtable-with-Version-key branch.Set-BuildEnvironmentbootstrap blocks are preserved (the repo-wide pattern also inHelp.tests.ps1, for running Pester in isolation), corrected to the scoped named-parameter rule (Split-Path -Path $x -Parent,Join-Path -Path … -ChildPath …, positionalImport-PowerShellDataFile $x).Select-String(first matching line's named capture — no loop, nobreak) rather than the template'sForEach-Object { … break }, whosebreakis unreliable inside a pipeline. The same fix is going upstream in PowerShellModuleTemplate#37, so this is a convergence, not a lasting divergence.Test plan
./build.ps1passes locally (build + Pester): 786 passed, 0 failed, 23 skipped🤖 Generated with Claude Code