Skip to content

Commit 788c60d

Browse files
authored
Merge pull request #2 from chrisdicarlo/pest-integration
Pest Integration
2 parents 96ae6b3 + 53e1031 commit 788c60d

File tree

5 files changed

+65
-38
lines changed

5 files changed

+65
-38
lines changed

.styleci.yml

Lines changed: 0 additions & 4 deletions
This file was deleted.

count-failed.xsl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
<!-- count-failed.xsl -->
12
<xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
23
<xsl:template match="/">
3-
<xsl:value-of select="count(tests/test[@status='3'])" />
4+
<xsl:value-of select="count(tests/test)" />
45
</xsl:template>
56
</xsl:stylesheet>

failed-tests.xsl

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,36 @@
66
<xsl:apply-templates />
77
</xsl:template>
88

9-
<xsl:template match="tests">
9+
<xsl:template match="tests">
10+
<xsl:apply-templates select="./test" />
11+
</xsl:template>
12+
13+
<xsl:template match="test">
14+
<xsl:call-template name="backslashescape">
15+
<xsl:with-param name="str" select="." />
16+
</xsl:call-template>
17+
18+
<xsl:if test="position() != last()">
19+
<xsl:text>|</xsl:text>
20+
</xsl:if>
21+
</xsl:template>
22+
23+
<xsl:template name="backslashescape">
24+
<xsl:param name="str" select="."/>
25+
<xsl:choose>
26+
<xsl:when test="contains($str, '\')">
27+
<xsl:value-of select="concat(substring-before($str, '\'), '\\' )"/>
28+
<xsl:call-template name="backslashescape">
29+
<xsl:with-param name="str" select="substring-after($str, '\')"/>
30+
</xsl:call-template>
31+
</xsl:when>
32+
<xsl:otherwise>
33+
<xsl:value-of select="$str"/>
34+
</xsl:otherwise>
35+
</xsl:choose>
36+
</xsl:template>
37+
38+
<!-- <xsl:template match="tests">
1039
<xsl:apply-templates select="./test[@status = '3']" />
1140
</xsl:template>
1241
@@ -15,5 +44,5 @@
1544
<xsl:if test="position() != last()">
1645
<xsl:text>|</xsl:text>
1746
</xsl:if>
18-
</xsl:template>
47+
</xsl:template> -->
1948
</xsl:stylesheet>

phpunit-failed-runner

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,29 @@
11
#!/bin/bash
22

3-
logfile=./testdox.xml
3+
logfile=./junit.xml
44

5-
if test -f "$logfile"; then
6-
echo "Logfile found. Searching for failed tests..."
5+
if [ -f "./vendor/bin/pest" ]; then
6+
runner="./vendor/bin/pest"
7+
else
8+
runner="./vendor/bin/phpunit"
9+
fi
710

8-
# Strip out everything except the failed tests just in
9-
# case they were run using a different tool or script
10-
xmlstarlet tr ./vendor/chrisdicarlo/phpunit-failed-runner/prune.xsl testdox.xml > testdoxTMP.xml
11-
mv testdoxTMP.xml testdox.xml
11+
if test -f "$logfile"; then
12+
echo -e "Logfile found. Searching for previously failing tests... \U23F3"
1213

13-
failed_tests="$(xmlstarlet tr --omit-decl ./vendor/chrisdicarlo/phpunit-failed-runner/failed-tests.xsl testdox.xml)"
14+
count_failed_tests="$(xmlstarlet tr ./vendor/chrisdicarlo/phpunit-failed-runner/prune.xsl junit.xml | xmlstarlet tr --omit-decl ./vendor/chrisdicarlo/phpunit-failed-runner/count-failed.xsl)"
1415

15-
if [ "$failed_tests" = "" ]; then
16-
echo "No failed tests! Great job!"
16+
if [ "$count_failed_tests" = "0" ]; then
17+
echo -e "No failed tests! Great job! \U1F44D \U1F389"
18+
rm "$logfile"
19+
exit 0
1720
else
18-
echo "Found failed tests, filtering..."
19-
./vendor/bin/phpunit --filter "'$failed_tests'"
21+
echo -e "Found $count_failed_tests previously failing tests, filtering... \U1F97A"
22+
filter=$(xmlstarlet tr ./vendor/chrisdicarlo/phpunit-failed-runner/prune.xsl junit.xml | xmlstarlet tr --omit-decl ./vendor/chrisdicarlo/phpunit-failed-runner/failed-tests.xsl); "$runner" --filter "$filter" --log-junit junit.xml
2023
fi
2124
else
22-
echo "Logfile not found. Running the full test suite..."
23-
./vendor/bin/phpunit
24-
fi
25-
26-
# Strip out everything except the failed tests
27-
xmlstarlet tr ./vendor/chrisdicarlo/phpunit-failed-runner/prune.xsl testdox.xml > testdoxTMP.xml
28-
mv testdoxTMP.xml testdox.xml
29-
30-
# If there are no more failed tests, remove the log file
31-
count_failed_tests="$(xmlstarlet tr --omit-decl ./vendor/chrisdicarlo/phpunit-failed-runner/count-failed.xsl testdox.xml)"
32-
33-
if [ "$count_failed_tests" = "0" ]; then
34-
rm ./testdox.xml
25+
echo -e "Logfile not found. Running the full test suite... \U1F91E"
26+
"$runner" --log-junit junit.xml
3527
fi
3628

3729
exit 0

prune.xsl

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
<xsl:stylesheet version="1.0"
22
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
33
<xsl:strip-space elements="*"/>
4-
<xsl:output omit-xml-declaration="no" indent="yes"/>
54

6-
<xsl:template match="node()|@*">
7-
<xsl:copy>
8-
<xsl:apply-templates select="node()|@*"/>
9-
</xsl:copy>
5+
<xsl:template match="/">
6+
<tests>
7+
<xsl:apply-templates />
8+
</tests>
109
</xsl:template>
1110

12-
<xsl:template match="test[not(@status='3')]"/>
11+
<xsl:template match="/testsuite">
12+
<tests>
13+
<xsl:apply-templates select="testcase" />
14+
</tests>
15+
</xsl:template>
16+
17+
<xsl:template match="testcase[error|failure]">
18+
<test>
19+
<xsl:value-of select="@class"/>::<xsl:value-of select="@name"/>
20+
</test>
21+
</xsl:template>
1322
</xsl:stylesheet>

0 commit comments

Comments
 (0)