Commit 329ca92
fix(tests): parse changelog version with Select-String instead of break 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>1 parent 01cca97 commit 329ca92
1 file changed
Lines changed: 9 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
148 | 152 | | |
149 | 153 | | |
150 | 154 | | |
| |||
0 commit comments