Skip to content

Instantly share code, notes, and snippets.

@rdammkoehler
Forked from hoodja/unity_to_junit.pl
Last active December 15, 2015 02:29
Show Gist options
  • Save rdammkoehler/5187778 to your computer and use it in GitHub Desktop.
Save rdammkoehler/5187778 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ -f "$1" ]
then
cat << END_OF_RESULTS
<testsuite>
$(
cat $1 | grep -Ee "^ *(IGNORE_)?TEST" | while read line; do
command=$(echo $line | \
sed \
-e 's/IGNORE_TEST(\([^,]*\), \([^)]*\)).*$/group="\1"; test="\2"; status="IGNORE";/' \
-e 's/TEST(\([^,]*\), \([^)]*\)) \(PASS\).*$/group="\1"; test="\2"; status="\3";/' \
-e 's/TEST(\([^,]*\), \([^)]*\))[^:]*:\([^:]*\):\([^:]*\):\([^:]*\):\(FAIL\):\(.*$\)/group="\1"; test="\2"; status="\6"; detail="\7"/')
eval "$command"
echo " <testcase classname=\"$group\" name=\"$test\">"
[[ "$status" == "IGNORE" ]] && echo " <skipped></skipped>"
[[ "$status" == "FAIL" ]] && echo " <failure>
<![CDATA[
$detail
]]>
</failure>"
echo " </testcase>"
done
)
</testsuite>
END_OF_RESULTS
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment