lint: Add junit.xml output for jenkins
To add lint to jenkins testing, we need junit.xml output. This adds an optional --junit command line parameter to enable output to an xml file in the lint directory. Change-Id: I5588190cb050b9dbe99458cb18a71a147769f50e Signed-off-by: Martin Roth <martinroth@google.com> Reviewed-on: http://review.coreboot.org/11891 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
This commit is contained in:
parent
e4fc407e3f
commit
b6d739d449
|
@ -18,7 +18,13 @@
|
||||||
#set -x # uncomment for debug
|
#set -x # uncomment for debug
|
||||||
|
|
||||||
usage () {
|
usage () {
|
||||||
printf "Usage: %s <lint|lint-stable>\n" "$0"
|
printf "Usage: %s <lint|lint-stable> [--junit]\n" "$0"
|
||||||
|
}
|
||||||
|
|
||||||
|
junit_write () {
|
||||||
|
if [ "$JUNIT" -eq 1 ]; then
|
||||||
|
echo "$1" >> "$XMLFILE"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -z "$1" ] || [ "$1" != "lint" ] && [ "$1" != "lint-stable" ]; then
|
if [ -z "$1" ] || [ "$1" != "lint" ] && [ "$1" != "lint-stable" ]; then
|
||||||
|
@ -27,24 +33,39 @@ if [ -z "$1" ] || [ "$1" != "lint" ] && [ "$1" != "lint-stable" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
LINTLOG=`mktemp .tmpconfig.lintXXXXX`;
|
LINTLOG=`mktemp .tmpconfig.lintXXXXX`;
|
||||||
|
XMLFILE="$(dirname $0)/junit.xml"
|
||||||
FAILED=0;
|
FAILED=0;
|
||||||
|
|
||||||
|
if [ "$2" = "--junit" ]; then
|
||||||
|
JUNIT=1
|
||||||
|
echo '<?xml version="1.0" encoding="utf-8"?>' > "$XMLFILE"
|
||||||
|
junit_write '<testsuite>'
|
||||||
|
else
|
||||||
|
JUNIT=0
|
||||||
|
fi
|
||||||
for script in util/lint/${1}-*; do
|
for script in util/lint/${1}-*; do
|
||||||
echo
|
echo
|
||||||
echo "$(basename $script)"
|
echo "$(basename $script)"
|
||||||
grep "^# DESCR:" $script | sed "s,.*DESCR: *,,"
|
grep "^# DESCR:" $script | sed "s,.*DESCR: *,,"
|
||||||
echo "========"
|
echo "========"
|
||||||
|
junit_write " <testcase classname='lint' name='$(basename $script)'>"
|
||||||
$script > $LINTLOG
|
$script > $LINTLOG
|
||||||
if [ `cat $LINTLOG | wc -l` -eq 0 ]; then
|
if [ `cat $LINTLOG | wc -l` -eq 0 ]; then
|
||||||
echo "success"
|
echo "success"
|
||||||
|
junit_write " <system-out><![CDATA[success]]></system-out>"
|
||||||
else
|
else
|
||||||
echo "test failed:"
|
echo "test failed:"
|
||||||
cat $LINTLOG
|
cat $LINTLOG
|
||||||
|
junit_write " <failure type='testFailed'><![CDATA["
|
||||||
|
junit_write "$(cat $LINTLOG)"
|
||||||
|
junit_write "]]></failure>"
|
||||||
rm -f $LINTLOG
|
rm -f $LINTLOG
|
||||||
FAILED=$(( $FAILED + 1 ))
|
FAILED=$(( $FAILED + 1 ))
|
||||||
fi
|
fi
|
||||||
echo "========"
|
echo "========"
|
||||||
|
junit_write ' </testcase>'
|
||||||
done
|
done
|
||||||
|
|
||||||
test $FAILED -eq 0 || { echo "ERROR: $FAILED test(s) failed."; rm -f $LINTLOG && exit 1; };
|
test $FAILED -eq 0 || { echo "ERROR: $FAILED test(s) failed."; rm -f $LINTLOG && exit 1; };
|
||||||
rm -f $LINTLOG
|
rm -f $LINTLOG
|
||||||
|
junit_write '</testsuite>'
|
||||||
|
|
Loading…
Reference in New Issue