Brian O'Connor
Committed by Ray Milkey

Updating checkstyle test for Buck

 - Updating grep regex which fails on Linux
 - Printing output for failed checkstyle runs

Change-Id: I905fe4b43a8c3948bca02d8bc73e88174735ac0b
......@@ -112,12 +112,17 @@ def osgi_jar(
if srcs:
chk_cmd = '#!/bin/bash\n'
base = get_base_path()
chk_cmd += 'OUT=$3\n'
chk_cmd += ' '.join(( 'java -jar $1',
'-c $2',
' '.join(['%s/%s' % (base, s) for s in srcs]) ))
chk_cmd += ' | grep -E "^[^: ]*:\d+:\d+: error:"'
'-c $2',
' '.join(['%s/%s' % (base, s) for s in srcs]) ))
chk_cmd += ' | tee $OUT'
chk_cmd += ' | grep -E "^.*[0-9]+:[0-9]+: error:"'
chk_cmd += ' | sed "s#^.*%s/#%s:#g"\n' % (base, name)
chk_cmd += 'test ${PIPESTATUS[0]} -eq 0\n' # status of java command
chk_cmd += 'RESULT=(${PIPESTATUS[*]})\n' # RESULT[0] is checkstyle result, RESULT[2] is grep
chk_cmd += 'test ${RESULT[2]} -eq 0 || cat $OUT\n'
chk_cmd += 'rm $OUT\n'
chk_cmd += 'exit ${RESULT[0]}'
genrule(
name = name + '-checkstyle-sh',
......@@ -131,7 +136,8 @@ def osgi_jar(
test = ':' + name + '-checkstyle-sh',
args = [
'$(location //lib:checkstyle)',
'$(location //tools/build/conf:checkstyle-xml)'
'$(location //tools/build/conf:checkstyle-xml)',
'`mktemp /tmp/%s-checkstyle-XXXXXX`' % name,
],
deps = [
':'+ bare_jar_name,
......