-
Notifications
You must be signed in to change notification settings - Fork 440
Description
Describe the bug
ANSI display sequences emitted by tests are displayed fine in regular output in a terminal (--show-output-of-passing-tests
). But if you use --report-formatter junit
, output includes 
, which is forbidden in XML 1.0 as far as I know. In particular, the Jenkins junit
step does not accept it, preventing the entire test suite from being reported.
To Reproduce
Run e.g.
kind create cluster
kubectl cluster-info
in a test suite. Record JUnit-format output and use https://plugins.jenkins.io/junit/ to display the test report. It will fail:
Failed to read test report file …/report.xml
org.dom4j.DocumentException: Error on line 1234 of document : Character reference "" is an invalid XML character.
at org.dom4j.io.SAXReader.read(SAXReader.java:511)
at org.dom4j.io.SAXReader.read(SAXReader.java:392)
at hudson.tasks.junit.SuiteResult.parse(SuiteResult.java:186)
In the XML you can see something like
<?xml version="1.0" encoding="UTF-8"?>
<!-- … -->
<system-out>$$$ [x.bats, line 123]
<!-- … -->
[0;32mKubernetes control plane[0m is running at [0;33mhttps://127.0.0.1:39377[0m
[0;32mCoreDNS[0m is running at [0;33mhttps://127.0.0.1:39377/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy[0m
<!-- … -->
Expected behavior
Either control characters are omitted from the XML, or U+001B is represented as e.g. ^[
, or (ideally) the entire ANSI code is stripped to produce plain text:
Kubernetes control plane is running at https://127.0.0.1:39377
CoreDNS is running at https://127.0.0.1:39377/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
Environment (please complete the following information):
- Bats version 1.10.0
- operating system (including version): Ubuntu 22.04.3
bash --version
: 5.1.16- Install method: clone &
install.sh