Pester icon indicating copy to clipboard operation
Pester copied to clipboard

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

Open ocalvo opened this issue 1 year ago • 4 comments

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

  • [x] PR has meaningful title
  • [x] Summary describes changes
  • [x] PR is ready to be merged
    • If not, use the arrow next to Create Pull Request to mark it as a draft. PR can be marked Ready for review when it's ready.
  • [x] Tests are added/update (if required)
  • [ ] Documentation is updated/added (if required)

ocalvo avatar Jun 25 '24 01:06 ocalvo

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

nohwnd avatar Jun 25 '24 08:06 nohwnd

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 avatar Jun 25 '24 17:06 ocalvo

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

ocalvo avatar Jun 25 '24 20:06 ocalvo

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

ocalvo avatar Jun 27 '24 17:06 ocalvo

/backport rel/5.6.x

nohwnd avatar Jul 01 '24 12:07 nohwnd

/backport to rel/5.6.x

nohwnd avatar Jul 01 '24 12:07 nohwnd

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

github-actions[bot] avatar Jul 01 '24 12:07 github-actions[bot]