Skip to content

Fix debug trace test - #1762

Draft
Steve Lee (SteveL-MSFT) wants to merge 2 commits into
PowerShell:mainfrom
SteveL-MSFT:psadapter-debug
Draft

Steve Lee (SteveL-MSFT) wants to merge 2 commits into
PowerShell:mainfrom
SteveL-MSFT:psadapter-debug

Conversation

@SteveL-MSFT

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

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.

1 participant