lambdaisland/kaocha-junit-xml

Captured test output is not properly escaped

ggiraldez opened this issue · 3 comments

The <system-out> tag which contains the raw captured output from a test is not properly escaped or wrapped in a <![CDATA[ ]]> section. This means the generated XML is invalid and cannot be parsed (eg. by CircleCI).

In my case, I'm running my tests through CircleCI and I have HikariCP logging:

...
18-11-16 15:22:28 erebus.local DEBUG [com.zaxxer.hikari.HikariConfig:1052] - dataSourceJNDI..................none
18-11-16 15:22:28 erebus.local DEBUG [com.zaxxer.hikari.HikariConfig:1052] - dataSourceProperties............{password=<masked>}
18-11-16 15:22:28 erebus.local DEBUG [com.zaxxer.hikari.HikariConfig:1052] - driverClassName.................none
...

CircleCI then complains with the message:

The following errors were encountered parsing test results:

kaocha/results.xml
    Unexpected close tag </system-out>; expected </masked>. at [row,col {unknown-source}]: [58,12]

As far as I can see, there's no provided way to escape the content using clojure.xml, but clojure.data.xml has a cdata function to wrap the content inside a <![CDATA[ ... ]]> element, and properly handles ]]> in the content.

This is shockingly broken behavior from clojure.xml, it really should entity-escape text nodes. I guess people don't really use clojure.xml/emit for real world stuff.

I'll have a patch out in a bit.

This is fixed in the latest release

;; deps.edn
lambdaisland/kaocha-junit-xml {:mvn/version "0.0-27"}

;; lein/boot
[lambdaisland/kaocha-junit-xml "0.0-27"]

Please try it out! Thanks.

Works like a charm! Thanks for the quick response! :)