Skip to content

Commit 35529d4

Browse files
author
Aaron Roller
authored
Merge pull request #5 from AutoModality/AM-415/rostests
Added support for single testsuite failure check
2 parents 9a0269b + 6065566 commit 35529d4

File tree

4 files changed

+64
-13
lines changed

4 files changed

+64
-13
lines changed

detection.sh

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,34 @@ file_or_folder="$1"
1010
# uses simple grep to look for failures="0" and errors="0"
1111

1212

13+
find_fail(){
14+
target=$1
15+
file=$2
16+
suite_line=$(cat "$file" | grep "$target")
17+
if echo "$suite_line" | grep "failures=\"0\"";then
18+
if echo "$suite_line" | grep "errors=\"0\"";then
19+
return 0
20+
else
21+
echo "Error found in $file: $suite_line"
22+
return 1
23+
fi
24+
else
25+
echo "Failure found in $file: $suite_line"
26+
return 1
27+
fi
28+
}
1329
suite_success(){
1430
file="$1"
1531
# look for 0 failures and errors
1632
# grep reports non zero code if anything but zero failures/errors
17-
if cat "$file" | grep "<testsuites";then
18-
suite_line=$(cat "$file" | grep "<testsuites")
19-
if echo "$suite_line" | grep "failures=\"0\"";then
20-
if echo "$suite_line" | grep "errors=\"0\"";then
21-
return 0
22-
else
23-
echo "Error found in $file: $suite_line"
24-
return 1
25-
fi
26-
else
27-
echo "Failure found in $file: $suite_line"
28-
return 1
29-
fi
33+
plural="<testsuites "
34+
singular="<testsuite "
35+
if cat "$file" | grep "$plural";then
36+
find_fail $plural $file
37+
return $?
38+
elif cat "$file" | grep "$singular";then
39+
find_fail $singular $file
40+
return $?
3041
else
3142
echo "Skipping file without suite: $file"
3243
fi

test/all.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ set -e
66

77
test/one.sh test/success_fixture.xml 0
88
test/one.sh test/failure_fixture.xml 1
9+
test/one.sh test/singular_testsuite_success_fixture.xml 0
10+
test/one.sh test/singular_testsuite_failure_fixture.xml 1
911
test/one.sh test/error_fixture.xml 1
12+
1013
test/one.sh test 1
1114
test/one.sh test/success 0
1215
test/one.sh test/failure 1
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<testsuite errors="0" failures="1" name="unittest.suite.TestSuite" tests="1" time="0.114"><testcase classname="rostest.runner.RosTest" name="testsuper_status" time="0.1142"><failure type="AssertionError">Test Fixture Nodes ['am_super'] failed to launch
2+
File "/usr/lib/python2.7/unittest/case.py", line 329, in run
3+
testMethod()
4+
File "/opt/ros/melodic/lib/python2.7/dist-packages/rostest/runner.py", line 121, in fn
5+
self.assert_(not failed, "Test Fixture Nodes %s failed to launch"%failed)
6+
File "/usr/lib/python2.7/unittest/case.py", line 422, in assertTrue
7+
raise self.failureException(msg)
8+
</failure></testcase><system-out>&lt;![CDATA[
9+
[ROSTEST]setup[/home/developer/catkin_ws/src/rostest/am_super_status.test] run_id[13387f10-ca87-11ea-ae12-0242ac110002] starting
10+
&amp;#x001B;[1mstarted roslaunch server http://94f83af5cd1d:36301/&amp;#x001B;[0m
11+
12+
SUMMARY
13+
========
14+
15+
PARAMETERS
16+
* /rosdistro: melodic
17+
* /rosversion: 1.14.5
18+
19+
NODES
20+
/
21+
am_super (am_super/am_super)
22+
23+
[ROSTEST]setup[/home/developer/catkin_ws/src/rostest/am_super_status.test] run_id[13387f10-ca87-11ea-ae12-0242ac110002] done
24+
[ROSTEST]Running test [super_status]
25+
&amp;#x001B;[1mROS_MASTER_URI=http://94f83af5cd1d:46481/&amp;#x001B;[0m
26+
&amp;#x001B;[1msetting /run_id to 13387f10-ca87-11ea-ae12-0242ac110002&amp;#x001B;[0m
27+
[ROSTEST]tearDown[/home/developer/catkin_ws/src/rostest/am_super_status.test]
28+
shutting down processing monitor...
29+
... shutting down processing monitor complete
30+
[ROSTEST]rostest teardown /home/developer/catkin_ws/src/rostest/am_super_status.test complete
31+
32+
]]&gt;</system-out><system-err>&lt;![CDATA[
33+
&amp;#x001B;[31mERROR: cannot launch node of type [am_super/am_super]: Cannot locate node of type [am_super] in package [am_super]. Make sure file exists in package path and permission is set to executable (chmod +x)&amp;#x001B;[0m
34+
35+
]]&gt;</system-err></testsuite>
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<testsuite errors="0" failures="0" name="unittest.suite.TestSuite" tests="1" time="0.114"><testcase classname="rostest.runner.RosTest" name="testsuper_status" time="0.1142">
2+
</testsuite>

0 commit comments

Comments
 (0)