Skip to content

Commit

Permalink
Added plain text test reporter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Corneil du Plessis committed Nov 5, 2024
1 parent 2a34ff8 commit 7cf5109
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ jobs:
timeout-minutes: 75
run: |
./mvnw -s .github/settings.xml -B -Pdocs clean install --no-transfer-progress -T 1C
- uses: ./.github/actions/install-xmlutils
- name: Test Report
shell: bash
run: ./src/scripts/print-test-errors.sh

scan:
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 8 additions & 0 deletions src/scripts/combine-fragment.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
PARENT=$(realpath $(dirname "$2" ))
set +e
xsltproc --load-trace --stringparam file $(basename "$PARENT") "$1" "$2"
RC=$?
if [ "$RC" != "0" ]; then
exit $RC
fi
29 changes: 29 additions & 0 deletions src/scripts/combine-testcases.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="file" select="'unknown'"/>
<xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="/testsuite">
<xsl:apply-templates select="testcase"/>
</xsl:template>
<xsl:template match="testcase">
<xsl:element name="testcase">
<xsl:attribute name="file">
<xsl:value-of select="$file"/>
</xsl:attribute>
<xsl:attribute name="classname">
<xsl:value-of select="@classname"/>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="@name"/>
</xsl:attribute>
<xsl:attribute name="time">
<xsl:value-of select="@time"/>
</xsl:attribute>
<xsl:copy-of select="skipped"/>
<xsl:copy-of select="error"/>
<xsl:copy-of select="system-out"/>
</xsl:element>
</xsl:template>
<xsl:template match="*"/>
</xsl:stylesheet>
17 changes: 17 additions & 0 deletions src/scripts/extract-failures.xsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output media-type="text/plain"/>
<xsl:template match="/">
<xsl:for-each select="testsuite/testcase">
<xsl:if test="(count(rerunError) + count(error)) > 0">
<xsl:text>== </xsl:text><xsl:value-of select="@classname"/><xsl:text>: </xsl:text><xsl:value-of select="@name"/>
<xsl:for-each select="error">
<xsl:text xml:space="preserve">: </xsl:text><xsl:value-of select="@message"/>
<xsl:text xml:space="preserve">
</xsl:text>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
8 changes: 8 additions & 0 deletions src/scripts/find-test-errors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
SCDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
DIR=$1
echo "<testsuite>" > combined.xml
set -e
find "$1" -name "*.xml" -exec $SCDIR/combine-fragment.sh "$SCDIR/combine-testcases.xsl" '{}' \; 2> /dev/null >> combined.xml
echo "</testsuite>" >> combined.xml
xsltproc $SCDIR/extract-failures.xsl combined.xml
3 changes: 3 additions & 0 deletions src/scripts/print-test-errors.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
SCDIR=$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")
find . -type d -name surefire-reports -exec $SCDIR/find-test-errors.sh {} \;
9 changes: 9 additions & 0 deletions src/scripts/print-test-file.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
FILE=$1
FAILED=$(grep -c -F "Failures: 0" $FILE)
ERRORS=$(grep -c -F "Errors: 0" $FILE)
RC2=$?
if (( (RC1 + RC2) > 0)); then
echo "RC1=$RC1, RC2=$RC2: $FILE"
cat $FILE
fi

0 comments on commit 7cf5109

Please sign in to comment.