Skip to content

test: Make the psake/Invoke-Build task drift guard able to fail, in both directions - #224

Open
tablackburn wants to merge 2 commits into
mainfrom
fix/215-ib-drift-guard
Open

test: Make the psake/Invoke-Build task drift guard able to fail, in both directions#224
tablackburn wants to merge 2 commits into
mainfrom
fix/215-ib-drift-guard

Conversation

@tablackburn

@tablackburn tablackburn commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #215. The Invoke-Build Tasks drift guard has never once compared a task name, and now compares them in both directions.

Three defects had to be fixed, not the two the issue describes. Each on its own was enough to make the comparison vacuous, and they cancelled out into a passing test:

  • $IBTasksResult was $null in the It that read it. It was assigned in a different It; the Describe-level $IBTasksResult = $null runs at discovery only, and Pester 5 does not carry a variable from one It into the next. The Invoke-Build job now runs in BeforeAll and both It blocks read $script:invokeBuildTaskName.
  • Invoke-PSake -docs piped through Receive-Job returns format records, which have no Name property, so every psake task name was $null. Replaced with Get-PSakeScriptTasks, projected to strings inside the job before they cross the serialization boundary.
  • Not in the issue: $IBTasksResult.All is an OrderedDictionary keyed by task name, so .All.Name was a lookup for a key called Name rather than an enumeration. Fixing only the two documented defects would still have compared psake's tasks against an empty list. The job now returns .All.Keys.

$null -notin $null is False, so the throw never fired, and an array of nulls satisfied Should -Not -BeNullOrEmpty.

The comparison is now bidirectional. A task defined in IB.tasks.ps1 and forgotten in psakeFile.ps1 leaves psake consumers without it — the same defect as #178 and #193 with the files swapped, and nothing else in the suite catches it. This matches the shape the signing comparison in this same file already uses. Each runner's own entry point is excluded on its own side: psake answers to default and ?, Invoke-Build to .. Nothing else is excluded.

Test plan

./build.ps1 -Task Test — green. Both directions were proved able to fail, not assumed:

Divergence introduced Result
Task Sign renamed in IB.tasks.ps1 fails — but got 'Sign'
Task ExtraInvokeBuildTask appended to IB.tasks.ps1 fails — but got 'ExtraInvokeBuildTask'
neither passes

Exactly one test fails in each case, so the neighbouring blocks are undisturbed.

The three other Describe blocks in this file — the settings comparison and README table checks from #178, and the signing settings comparison from #193 — are untouched.

Breaking changes

None. Test suite only.

No CHANGELOG.md entry: instructions/repository-specific.instructions.md scopes the changelog to user-facing changes to the shipped module and excludes the test suite. Nothing under PowerShellBuild/ changed.

Local variable names in the block being rewritten were expanded per shorthand.instructions.md ($outputModVerDir became $outputModuleVersionPath, and similar).

Copilot AI lite review requested due to automatic review settings August 28, 2026 21:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Aug 28, 2026

Copy link
Copy Markdown

Test Results

    4 files  ±0    889 suites  ±0   2m 6s ⏱️ -21s
  596 tests ±0    593 ✅ ±0   3 💤 ±0  0 ❌ ±0 
2 367 runs  ±0  2 295 ✅ ±0  72 💤 ±0  0 ❌ ±0 

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.
Invoke-Build Tasks.Contains all the tasks that were in the Psake file
Invoke-Build Tasks.defines the same tasks in both task files

♻️ This comment has been updated with latest results.

tablackburn and others added 2 commits August 28, 2026 18:04
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
tablackburn force-pushed the fix/215-ib-drift-guard branch from e7f9a2c to a28ac72 Compare August 28, 2026 22:21
@tablackburn tablackburn changed the title test: Make the psake/Invoke-Build task drift guard able to fail test: Make the psake/Invoke-Build task drift guard able to fail, in both directions Aug 28, 2026
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.

The psake/Invoke-Build task drift guard compares nothing against nothing

2 participants