mocha
mocha copied to clipboard
fix: remove ansi escape sequences from escaped xunit output
Requirements
- Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
- All new code requires tests to ensure against regressions.
Description of the Change
The utils.escape function is amended to strip the escape sequence using a regular expression.
Alternate Designs
- patch the underlying
helibrary: dismissed because the direct fix is likely faster to become usable - filter the output before running
he: dismissed because the correct escaping in JavaScript is harder to find - filter out all invalid XML characters: dismissed because this is not a problem observed with other characters
Why should this be in core?
The xunit reporter is in core and should not be buggy
Benefits
xunit reporter output can be consumed by tools that expect valid XML
Possible Drawbacks
Tools that process the XML as plain (unicode) text (unlikely) can no longer see the ANSI escape sequence.
Applicable issues
fixes #4526
This is a bug fix (patch release)
Coverage remained the same at 94.143% when pulling d41753887fcba8aba06409a5ba2ab5509305bdaf on trieloff:issue/4526 into bc8ce0535d2b94c6f4cd3c23a0d9ccce87d6e53b on mochajs:master.
There is a related xunit issue #3586.
This PR hasn't had any recent activity, and I'm labeling it stale. Remove the label or comment or this PR will be closed in 14 days. Thanks for contributing to Mocha!
This issue has been hanging around for 8 months now, and I'm unsure what I can do to get it moving again. There is an open thread that has multiple possible solutions to the problem, but no expression of preference from the Mocha team.
👋 coming back to this @trieloff, are you still interested in working on this PR? As of https://github.com/mochajs/mocha/issues/5027 there are again maintainers who can review it now. No worries if you no longer have time - but if you do that'd be great!
Hi @JoshuaKGoldberg – that's unexpected – but not unwelcome. I'm happy to rebase the PR to the latest main. Do you want to reopen this PR or have me create a new one?
Great! Let's go ahead and reopen this one.
We also discussed that we don't like the requirement of rebasing, so if you want to do a more casual merge that works too. Whatever's easiest on your end. 🙂
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: trieloff / name: Lars Trieloff (717474ab9616679ccc6039d4fd7d90a336d7393a, 9f3f8db00cac3db3c014a0bfeabf275e54728bc5, bfb62dc148d5f6e8be4d5171d34ce82a8c5dfb63, d41753887fcba8aba06409a5ba2ab5509305bdaf, b4b7392504a9f773833fe79bcec3261eb9bc4e32, 51cd81ca131ef6538411b4d6ace9e010979ed10c, 9d6dc63f4bfdfd11271ccf14e1f2c77371d947d9)
Ok, let me get that CLA signed, then.
- CLA has been signed (thanks, corporate overlords)
masterhas been merged- conflicts have been resolved
@JoshuaKGoldberg can I get some eyes on this, please?
Yes! Thanks for the prod - this slipped off my radar. Reviewing now!