pester / Pester

Pester is the ubiquitous test and mock framework for PowerShell.
https://pester.dev/
Other
3.05k stars 469 forks source link

Fix a bug where the NUnit-Report fails to generate if the test output contains Virtual Terminal Sequences #2511

Closed ocalvo closed 2 weeks ago

ocalvo commented 3 weeks ago

PR Summary

The following test will fail to generate an NUnit report:

Describe 'Describe VT Sequences' {
  Write-Output "`e[32mHello World`e[0m"
  $true | Should -Be $true
}

This will fail because WriteCData does not support writting the ESC character, which is a valid VT sequence. The fix is to replace the ESC and Bell characters for {ESC} and {BELL}. According to the Xml CDATA spec, there is no way to escape these characters, other than failing, but we still need to represent them in the NUnit report. Afte this change, these characters will be represented as by its printable version in the unicode table: for the ESC (0x1B) and as for the BELL (0x07) in the resulting Xml CData for example.

PR Checklist

nohwnd commented 3 weeks ago

Hello, thanks for the PR, the test you added is failing. I assume you also want this backported to version 5.x.x ?

ocalvo commented 3 weeks ago

Hello, thanks for the PR, the test you added is failing. I assume you also want this backported to version 5.x.x ?

No, we can easily update our test suite to latest version.

ocalvo commented 2 weeks ago

@nohwnd I have fixed the test, it was failling because WindowsPowerShell does not escape the ESC character. Fixed using the ASCII value explicitly.

ocalvo commented 2 weeks ago

Hi @nohwnd , we are blocked by this, we would appreciate if you could review at your earliest convenience.

nohwnd commented 2 weeks ago

/backport rel/5.6.x

nohwnd commented 2 weeks ago

/backport to rel/5.6.x

github-actions[bot] commented 2 weeks ago

Started backporting to rel/5.6.x: https://github.com/pester/Pester/actions/runs/9744568632