Skip to content

Fix test reliability and DEBUG assertion correctness for &! operator#163

Closed
Copilot wants to merge 2 commits intothreadJobOperatorfrom
copilot/sub-pr-162
Closed

Fix test reliability and DEBUG assertion correctness for &! operator#163
Copilot wants to merge 2 commits intothreadJobOperatorfrom
copilot/sub-pr-162

Conversation

Copy link

Copilot AI commented Mar 11, 2026

Review feedback on the &! (ThreadJob background operator) implementation identified brittle test patterns and a broken DEBUG assertion.

Test fixes (ThreadJobBackgroundOperator.Tests.ps1)

  • TypeName detection: Replaced $job.PSObject.TypeNames | Should -Contain 'ThreadJob' with $job.PSJobTypeName | Should -Be 'ThreadJob'PSJobTypeName is the canonical property; TypeNames is implementation-specific and unreliable for this check
  • Job cleanup: Wrapped all runtime It blocks in try/finally with Remove-Job -Force -ErrorAction Ignore so jobs are removed even on assertion failure
  • Hang prevention: All Wait-Job calls now use -Timeout 30; tests throw explicitly if the timeout is hit rather than blocking the suite indefinitely
$job = Write-Output "ThreadJob Test" &!
try {
    $job.PSJobTypeName | Should -Be 'ThreadJob'
    $completedJob = $job | Wait-Job -Timeout 30
    if (-not $completedJob) {
        throw "Job did not complete within the allotted timeout (30 seconds)."
    }
}
finally {
    if ($null -ne $job) { $job | Remove-Job -Force -ErrorAction Ignore }
}

Token table assertion fix (token.cs)

The DEBUG-only Diagnostics.Assert calls validating s_staticTokenFlags and s_tokenText table lengths were still anchored to TokenKind.Clean (170) as the last enum value. With AmpersandExclaim = 171 appended, these assertions would fire in DEBUG builds. Updated to use TokenKind.AmpersandExclaim as the sentinel.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

… add Wait-Job timeouts, fix DEBUG assertions

Co-authored-by: kilasuit <6355225+kilasuit@users.noreply.github.com>
Copilot AI changed the title [WIP] Add ThreadJobOperator Fix test reliability and DEBUG assertion correctness for &! operator Mar 11, 2026
@kilasuit kilasuit closed this Mar 11, 2026
Repository owner locked and limited conversation to collaborators Mar 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants