test: Make the psake/Invoke-Build task drift guard able to fail, in both directions - #224
Open
tablackburn wants to merge 2 commits into
Open
test: Make the psake/Invoke-Build task drift guard able to fail, in both directions#224tablackburn wants to merge 2 commits into
tablackburn wants to merge 2 commits into
Conversation
Test Results 4 files ±0 889 suites ±0 2m 6s ⏱️ -21s Results for commit a28ac72. ± Comparison against base commit 3ea9e82. This pull request removes 1 and adds 1 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
The 'Contains all the tasks that were in the Psake file' test has never compared a task name. Three defects cancelled out: - $IBTasksResult was assigned in a different It block, so it was $null in the block that read it. The Invoke-Build job now runs in the Describe's BeforeAll and both It blocks read the same $script: variable. - Invoke-PSake -docs writes a formatted table, so format records with no Name property crossed the job boundary and every psake task name was $null. Get-PSakeScriptTasks returns task objects, and the job projects the names to strings before they are serialized. - $IBTasksResult.All is an ordered dictionary keyed by task name, so .Name looked up a key that does not exist rather than enumerating the names. The job returns .All.Keys. Renaming Task Sign in IB.tasks.ps1 now fails the test with "but got 'Sign'"; before this change the whole suite stayed green. Closes #215 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011GYJrhbrDzqufaeMqD9QjT
A task defined in IB.tasks.ps1 and forgotten in psakeFile.ps1 leaves psake consumers without it, which is the same defect as #178 and #193 with the files swapped, and nothing else in the suite catches it. The guard now asserts both directions with a Because of its own, matching the shape the signing comparison in this file already uses, and the It is renamed to say what it does. Each runner's own entry point is excluded on its own side: psake answers to 'default' and '?', Invoke-Build to '.'. Nothing else is excluded. Measured: appending Task ExtraInvokeBuildTask to IB.tasks.ps1 fails with "but got 'ExtraInvokeBuildTask'", and renaming Task Sign there still fails with "but got 'Sign'". Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011GYJrhbrDzqufaeMqD9QjT
tablackburn
force-pushed
the
fix/215-ib-drift-guard
branch
from
August 28, 2026 22:21
e7f9a2c to
a28ac72
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/IBTasks.tests.ps1, which has never compared a taskname (The psake/Invoke-Build task drift guard compares nothing against nothing #215), and makes the comparison bidirectional
because fixing any one alone turns the test red for the wrong reason
Describeblocks in the file (added in IB.tasks.ps1 reads a nonexistent CodeCoverage.OutputFormat setting, so Invoke-Build users get $null #178 and $PSBPreference.Sign.SkipCertificateValidation has no effect on the Store and Thumbprint sources it is documented for #193) are untouchedThe three defects
$IBTasksResultwas assigned in oneItand read in the next. EachItruns in its ownscope, and the
$IBTasksResult = $nullat theDescribelevel runs at discovery only, sothe reader saw
$null. The Invoke-Build job now runs once in theDescribe'sBeforeAlland both
Itblocks read$script:invokeBuildTaskName.Invoke-PSake -docswrites a formatted table, so format records crossed the jobboundary, not task objects. They have no
Nameproperty, so every psake name was$null.Get-PSakeScriptTasks -buildFilereturns task objects, and the job projects the names tostrings before they are serialized.
$IBTasksResult.Allis anOrderedDictionarykeyed by task name, so.All.Nameis a lookup for a key calledName, not an enumeration of the names. It isempty in-process and after serialization alike, so fixing only the scoping defect would
still have compared psake's tasks against an empty list. The job returns
.All.Keys.$null -notin $nullisFalse, so the oldthrownever fired, and the closingShould -Not -BeNullOrEmptypassed on an array of 21 nulls.Both directions
A task defined in
IB.tasks.ps1and forgotten inpsakeFile.ps1leaves psake consumerswithout it — the same defect as #178 and #193 with the files swapped — and nothing else in the
suite catches it. The
Itis renamed todefines the same tasks in both task filesandasserts
$missingFromInvokeBuildand$missingFromPsakeseparately, each with its own-Because, matching theSigning settings referenced by the task filesblock in this file.Each runner's own entry point is excluded on its own side, with the reason in a comment: psake
answers to
defaultand?, Invoke-Build to.. Nothing else is excluded.Test plan
./build.ps1 -Task Teston Windows 11, PowerShell 7.6.5, Pester 6.1.0, psake 5.0.4,InvokeBuild 5.14.23. Each run was checked against the rebuilt files in
Output/to confirm theprobe was present or absent as intended.
Red, psake task missing from Invoke-Build —
Task Sign SignModule, SignCatalogrenamed toTask RenamedSignTask ...inPowerShellBuild/IB.tasks.ps1:Red, Invoke-Build task missing from psake —
Task ExtraInvokeBuildTask {}appended toPowerShellBuild/IB.tasks.ps1. An addition is the only probe that isolates this direction,since a rename diverges both at once:
Before this change, neither divergence failed anything — the measurement in #215.
Green — both probes reverted, neither name present in the built task files:
Both runners report the same 16 tasks.
Notes
BeforeAlllost their abbreviations ($outputModVerDirbecame$outputModuleVersionPath) while those lines were being edited, per the shorthandinstructions.
CHANGELOG.mdentry: a test-suite repair with no change to the shipped module, andrepository-specific.instructions.mdscopes the changelog to user-facing changes.Closes #215