Last active
February 28, 2023 15:45
-
-
Save benasher44/b3cdf4060d4eac24eff85ef08816ffc0 to your computer and use it in GitHub Desktop.
K/N GTest Output to JUnit XML using sed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Escape XML characters | |
s/&/\&/g | |
s/"/\"/g | |
s/'/\'/g | |
s/</\</g | |
s/>/\>/g | |
s/\[==========\] Running ([0-9]+) tests from [0-9]+ test cases./<testsuites><testsuite tests="\1">/g | |
s/\[ RUN \] ([[:alnum:]_-]+)\.(.+)/<testcase classname="\1" name="\2">/g | |
s/\[----------\].+//g | |
s/YOU HAVE [0-9]+ DISABLED TEST\(S\)//g | |
# lines that start with a letter are usually an exception being thrown; start a failure node | |
s/^([[:alpha:]].+)/<failure>\1/ | |
s#\[ FAILED \].+ ms\)#</failure></testcase>#g | |
s#\[ OK \].+ ms\)#</testcase>#g | |
s#\[==========\] ([0-9]+) tests from ([0-9]+) test cases ran.+#</testsuite></testsuites>#g | |
s/\[ PASSED \] [0-9]+ tests\.//g | |
s/\[ FAILED \] [0-9]+ tests,.+//g | |
s/\[ FAILED \] .+//g | |
s/[0-9]+ FAILED TESTS//g |
Would need to use a real programming language to capture test times testcase nodes
Updated to support ignored tests
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage: