Skip to content

test: align Manifest test with canonical template (dependency version checks + ManifestHelpers)#22

Merged
tablackburn merged 3 commits into
mainfrom
test/align-manifest-test-with-template
May 29, 2026
Merged

test: align Manifest test with canonical template (dependency version checks + ManifestHelpers)#22
tablackburn merged 3 commits into
mainfrom
test/align-manifest-test-with-template

Conversation

@tablackburn
Copy link
Copy Markdown
Owner

@tablackburn tablackburn commented May 27, 2026

Summary

Brings tests/Manifest.tests.ps1 up 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. Provides Test-VersionConstraint (and its Split-SemVerString / Compare-SemVerPrerelease / Test-VersionComparison internals) 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 RequiredModules against 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 (RequiredVersionEqual)
  • <dep> has a maximum version >= (MaximumVersionGreaterOrEqual)
  • <dep> has a minimum version <= (ModuleVersionLessOrEqual)

Plain-string references, duplicate entries, and missing/empty versions are handled with clear skips/throws. Adds $manifestRawData (Import-PowerShellDataFile of the built manifest) so the raw version keys are inspectable.

For fidelity with the canonical source, the template-only $isTemplate skip guard on "Changelog and manifest versions are the same" and the -Skipped Describe '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.psd1 is read instead of the template's requirements.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.
  • psake Set-BuildEnvironment bootstrap blocks are preserved (the repo-wide pattern also in Help.tests.ps1, for running Pester in isolation), corrected to the scoped named-parameter rule (Split-Path -Path $x -Parent, Join-Path -Path … -ChildPath …, positional Import-PowerShellDataFile $x).
  • Changelog parse uses Select-String (first matching line's named capture — no loop, no break) rather than the template's ForEach-Object { … break }, whose break is 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.ps1 passes locally (build + Pester): 786 passed, 0 failed, 23 skipped
  • CI passes on Linux / macOS / Windows
  • PSScriptAnalyzer clean

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings May 27, 2026 04:32
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 27, 2026

Warning

Review limit reached

@tablackburn, we couldn't start this review because you've reached your PR review rate limit.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ed59492a-1af0-441c-b798-20de434617b1

📥 Commits

Reviewing files that changed from the base of the PR and between 5398591 and 26b287b.

📒 Files selected for processing (2)
  • tests/Manifest.tests.ps1
  • tests/ManifestHelpers.psm1
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/align-manifest-test-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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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 manifest tests with the newer template-style dependency validation flow and adds a helper module for SemVer-aware version constraint checks.

Changes:

  • Adds ManifestHelpers.psm1 with SemVer comparison and constraint validation helpers.
  • Updates Manifest.tests.ps1 bootstrap/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.

Comment thread tests/Manifest.tests.ps1
Comment thread tests/Manifest.tests.ps1
Comment thread tests/Manifest.tests.ps1
Comment thread tests/Manifest.tests.ps1
Comment thread tests/Manifest.tests.ps1
Comment thread tests/Manifest.tests.ps1
Comment thread tests/Manifest.tests.ps1
… 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>
@tablackburn
Copy link
Copy Markdown
Owner Author

Resolving the Set-ItResult -Skipped review threads: they flag a fall-through that does not occur in Pester 5.

Set-ItResult ends in throw [Pester.Factory]::CreateErrorRecord(...), which unwinds the It block and is caught by Pester as a Skipped result — so when a skip condition is met, execution never reaches Test-VersionConstraint or the $dependencyRawData dereferences below it. Verified empirically on Pester 5.7.1: an It that calls Set-ItResult -Skipped followed immediately by throw reports Skipped, not Failed, and the line after the skip never runs.

An explicit return after the skip would therefore be unreachable dead code. (The awesome-copilot Pester v5 guidance likewise lists Set-ItResult -Skipped for runtime skipping with no accompanying return.)

Resolving these threads as not applicable.

tablackburn added a commit to tablackburn/PowerShellModuleTemplate that referenced this pull request May 28, 2026
…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>
@tablackburn
Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 28, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@tablackburn tablackburn merged commit 869cafa into main May 29, 2026
12 checks passed
@tablackburn tablackburn deleted the test/align-manifest-test-with-template branch May 29, 2026 00:14
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