Skip to content

Commit 34bdc54

Browse files
author
Aaron Roller
authored
Merge pull request #11 from terencejeong/master
Fixes #6 Fixed check for error fields and failure fields to be more robust
2 parents 091462f + 05dec1a commit 34bdc54

File tree

4 files changed

+54
-6
lines changed

4 files changed

+54
-6
lines changed

detection.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ find_fail(){
1515
file=$2
1616
suite_line=$(cat "$file" | grep "$target")
1717
if echo "$suite_line" | grep "failures=\"0\"";then
18-
if echo "$suite_line" | grep -L "errors=\"0\"";then
19-
return 0
20-
else
18+
if echo "$suite_line" | grep -L "errors=\"[1-9]\d*\"";then
2119
echo "Error found in $file: $suite_line"
2220
return 1
21+
else
22+
return 0
2323
fi
2424
elif echo "$suite_line" | grep -L "errors=\"0\"";then
25-
if echo "$suite_line" | grep "failures=\"0\"";then
26-
return 0
27-
else
25+
if echo "$suite_line" | grep -L "failures=\"[1-9]\d*\"";then
2826
echo "Error found in $file: $suite_line"
2927
return 1
28+
else
29+
return 0
3030
fi
3131
else
3232
echo "Failure found in $file: $suite_line"

test/all.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,14 @@ test/one.sh test/failure_fixture.xml 1
99
test/one.sh test/singular_testsuite_success_fixture.xml 0
1010
test/one.sh test/singular_testsuite_failure_fixture.xml 1
1111
test/one.sh test/error_fixture.xml 1
12+
test/one.sh test/no_error_field_fixture_success.xml 0
13+
test/one.sh test/no_error_field_fixture_failure.xml 1
1214

1315
test/one.sh test 1
1416
test/one.sh test/success 0
1517
test/one.sh test/failure 1
1618
test/one.sh test/error 1
1719
test/one.sh missing.xml 0
1820
test/one.sh test/missing.xml 0
21+
test/one.sh test/no_error_field_fixture.xml 0
22+
test/one.sh test/no_error_field_fixture_failure.xml 1
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites tests="5" failures="1" disabled="0" timestamp="2020-06-05T02:02:29" time="0.002" name="AllTests">
3+
<testsuite name="StrCompare" tests="5" failures="2" disabled="0" errors="0" time="0.002">
4+
<testcase name="CStrEqual" status="run" time="0" classname="StrCompare" />
5+
<testcase name="CStrEqual2" status="run" time="0" classname="StrCompare" />
6+
<testcase name="CStrEqual3" status="run" time="0" classname="StrCompare" />
7+
<testcase name="CStrNotEqual" status="run" time="0" classname="StrCompare">
8+
<failure message="/github/workspace/catkin_ws/src/am_super/test/sample_tests.cpp:27&#x0A; Expected: expectVal&#x0A; Which is: &quot;hello gtest&quot;&#x0A;To be equal to: actualValFalse&#x0A; Which is: &quot;hello world&quot;" type=""><![CDATA[/github/workspace/catkin_ws/src/am_super/test/sample_tests.cpp:27
9+
Expected: expectVal
10+
Which is: "hello gtest"
11+
To be equal to: actualValFalse
12+
Which is: "hello world"]]></failure>
13+
</testcase>
14+
<testcase name="CStrNotEqual4" status="run" time="0.002" classname="StrCompare">
15+
<failure message="/github/workspace/catkin_ws/src/am_super/test/sample_tests.cpp:32&#x0A; Expected: expectVal&#x0A; Which is: &quot;hello gtest&quot;&#x0A;To be equal to: actualValFalse&#x0A; Which is: &quot;hello world&quot;" type=""><![CDATA[/github/workspace/catkin_ws/src/am_super/test/sample_tests.cpp:32
16+
Expected: expectVal
17+
Which is: "hello gtest"
18+
To be equal to: actualValFalse
19+
Which is: "hello world"]]></failure>
20+
</testcase>
21+
</testsuite>
22+
</testsuites>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<testsuites tests="5" failures="0" disabled="0" timestamp="2020-06-05T02:02:29" time="0.002" name="AllTests">
3+
<testsuite name="StrCompare" tests="5" failures="2" disabled="0" errors="0" time="0.002">
4+
<testcase name="CStrEqual" status="run" time="0" classname="StrCompare" />
5+
<testcase name="CStrEqual2" status="run" time="0" classname="StrCompare" />
6+
<testcase name="CStrEqual3" status="run" time="0" classname="StrCompare" />
7+
<testcase name="CStrNotEqual" status="run" time="0" classname="StrCompare">
8+
<failure message="/github/workspace/catkin_ws/src/am_super/test/sample_tests.cpp:27&#x0A; Expected: expectVal&#x0A; Which is: &quot;hello gtest&quot;&#x0A;To be equal to: actualValFalse&#x0A; Which is: &quot;hello world&quot;" type=""><![CDATA[/github/workspace/catkin_ws/src/am_super/test/sample_tests.cpp:27
9+
Expected: expectVal
10+
Which is: "hello gtest"
11+
To be equal to: actualValFalse
12+
Which is: "hello world"]]></failure>
13+
</testcase>
14+
<testcase name="CStrNotEqual4" status="run" time="0.002" classname="StrCompare">
15+
<failure message="/github/workspace/catkin_ws/src/am_super/test/sample_tests.cpp:32&#x0A; Expected: expectVal&#x0A; Which is: &quot;hello gtest&quot;&#x0A;To be equal to: actualValFalse&#x0A; Which is: &quot;hello world&quot;" type=""><![CDATA[/github/workspace/catkin_ws/src/am_super/test/sample_tests.cpp:32
16+
Expected: expectVal
17+
Which is: "hello gtest"
18+
To be equal to: actualValFalse
19+
Which is: "hello world"]]></failure>
20+
</testcase>
21+
</testsuite>
22+
</testsuites>

0 commit comments

Comments
 (0)