KeyError: 'testsuites' when using --junit-xml options with ctest output
Quick Information
- Ubuntu 18.04
- cmake 3.21.3
- badges-gitlab 0.8.1
What Happened?
CMake 3.21 recently introduced the --output-junit
option for generating a junit xml file with ctest. This is especially useful for continuous integration with gitlab.
When calling badges-gitlab
on this xml, I get the following error:
Traceback (most recent call last):
File "/usr/local/bin/badges-gitlab", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.9/dist-packages/badges_gitlab/cli.py", line 59, in main
create_badges_test(args.path, args.junit)
File "/usr/local/lib/python3.9/dist-packages/badges_gitlab/badges_test.py", line 86, in create_badges_test
testsuites = content['testsuites']['testsuite']
KeyError: 'testsuites'
Explanation
This error occurs because junit xml file produced by ctest does not contain a <testsuites>
node (see attached example).
Steps to reproduce
Download attached notestsuites.xml
file and execute:
badges-gitlab --junit-xml notestsuites.xml
notestsuites.xml
Priority/Severity
-
High (anything that impacts the normal user flow or blocks app usage)
Edited by Benjamin Maréchal