Skip to content

Fix debug trace test - #1762

Merged
Mikey Lombardi (He/Him) (michaeltlombardi) merged 2 commits into
PowerShell:mainfrom
SteveL-MSFT:psadapter-debug
Oct 19, 2026
Merged

Mikey Lombardi (He/Him) (michaeltlombardi) merged 2 commits into
PowerShell:mainfrom
SteveL-MSFT:psadapter-debug

Conversation

@SteveL-MSFT

@SteveL-MSFT Steve Lee (SteveL-MSFT) commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

PR Summary

The PSAdapter Write-Debug test fails inconsistently on macOS. macOS is known to not flush stdio buffers when a process exits so there's a race condition where the pwsh process has exited before the debug trace was written to stderr. The timing of this seems to be due to the Write-Error in the test class that follows Write-Debug. Due to PSAdapter setting $ErrorActionPreference = 'stop' the Write-Error results in an exception that is caught and exits the adapter before the debug message is written out.

Two changes:

  • In the PSAdapter, write the trace queue before writing the exception. This shouldn't affect this problem, but this order is correct
  • In the test class, explicitly set $ErrorActionPreference = 'continue' since the test is only trying to write an error trace and not throw an exception

Reran the macOS adapter test 5 times with no failures

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused changes consistently address the test’s unintended termination, with no unresolved findings; tests were not executed.

No open issues 🎉

What changed in this PR

Stabilizes the PowerShell adapter’s debug-trace test on macOS by avoiding an unintended terminating error.

Changes:

  • Makes the test resource’s error non-terminating.
  • Updates stream tests to expect successful exit codes.
  • Drains queued traces before logging adapter exceptions.
File Description
adapters/​powershell/​Tests/​TestClassResource/​0.0.1/​TestClassResource.psm1 Sets error handling to continue.
adapters/​powershell/​Tests/​powershellgroup.resource.tests.ps1 Updates expected exit codes.
adapters/​powershell/​psDscAdapter/​powershell.resource.ps1 Writes queued traces before exceptions.

Review effort: Balanced

Merged via the queue into PowerShell:main with commit 37a09b5 Oct 19, 2026
77 checks passed
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.

3 participants