From b6d739d4496d479315b74972ba3787653745e56f Mon Sep 17 00:00:00 2001 From: Martin Roth Date: Tue, 13 Oct 2015 15:04:17 -0600 Subject: 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 Reviewed-on: http://review.coreboot.org/11891 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi --- util/lint/lint | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'util/lint') diff --git a/util/lint/lint b/util/lint/lint index ab930398bc..fa47fb443e 100755 --- a/util/lint/lint +++ b/util/lint/lint @@ -18,7 +18,13 @@ #set -x # uncomment for debug usage () { - printf "Usage: %s \n" "$0" + printf "Usage: %s [--junit]\n" "$0" +} + +junit_write () { + if [ "$JUNIT" -eq 1 ]; then + echo "$1" >> "$XMLFILE" + fi } if [ -z "$1" ] || [ "$1" != "lint" ] && [ "$1" != "lint-stable" ]; then @@ -27,24 +33,39 @@ if [ -z "$1" ] || [ "$1" != "lint" ] && [ "$1" != "lint-stable" ]; then fi LINTLOG=`mktemp .tmpconfig.lintXXXXX`; +XMLFILE="$(dirname $0)/junit.xml" FAILED=0; +if [ "$2" = "--junit" ]; then + JUNIT=1 + echo '' > "$XMLFILE" + junit_write '' +else + JUNIT=0 +fi for script in util/lint/${1}-*; do echo echo "$(basename $script)" grep "^# DESCR:" $script | sed "s,.*DESCR: *,," echo "========" + junit_write " " $script > $LINTLOG if [ `cat $LINTLOG | wc -l` -eq 0 ]; then echo "success" + junit_write " " else echo "test failed:" cat $LINTLOG + junit_write " " rm -f $LINTLOG FAILED=$(( $FAILED + 1 )) fi echo "========" + junit_write ' ' done test $FAILED -eq 0 || { echo "ERROR: $FAILED test(s) failed."; rm -f $LINTLOG && exit 1; }; rm -f $LINTLOG +junit_write '' -- cgit v1.2.3