haf / expecto

A smooth testing lib for F#. APIs made for humans! Strong testing methodologies for everyone!
Apache License 2.0
663 stars 96 forks source link

JUnit XML can contain invalid escape sequences #434

Open pbiggar opened 2 years ago

pbiggar commented 2 years ago

Same issue as #324 (which is closed as they found a workaround).

Expecto is generating junit files with invalid xml, such as &#xA, for example:

<?xml version="1.0" encoding="utf-8"?>
<testsuites>
  <testsuite name="Nemo.Processors.RP65816.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
    <testcase name="addressing/absolute address x, long/always fails" time="0.065">
      <failure message="&#xA;.&#xA;&#x1B;[32mexpected&#x1B;[36m: &#x1B;[32m2&#x1B;[36m&#xA;&#x1B;[31m  actual&#x1B;[36m: &#x1B;[31m1&#x1B;[36m&#xA;   at Nemo.Processors.RP65816.Tests.ModeTests.modes@137-6.Invoke(Unit unitVar) in /home/adam/Repos/nemo/Nemo.Processors.RP65816.Tests/src/ModeTests.fs:line 137&#xA;   at Expecto.Impl.execTestAsync@935-1.Invoke(Unit unitVar) in C:\Users\Anthony Lloyd\src\expecto\Expecto\Expecto.fs:line 939&#xA;   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvoke[T,TResult](AsyncActivation`1 ctxt, TResult result1, FSharpFunc`2 part2)&#xA;   at &lt;StartupCode$FSharp-Core&gt;.$Async.StartChild@1641-5.Invoke(AsyncActivation`1 ctxt)&#xA;   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction)" />
    </testcase>
</testsuites>

As a result, none of the xml file readers I've tried is able to parse it, including CircleCI which I want to use it to give me analytics.

The workaround is to use --colours 0 but that removes colours from console output, which isn't what we want either. We should never be putting this invalid XML into the XML files.