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( ...@@ -112,12 +112,17 @@ def osgi_jar(
112 if srcs: 112 if srcs:
113 chk_cmd = '#!/bin/bash\n' 113 chk_cmd = '#!/bin/bash\n'
114 base = get_base_path() 114 base = get_base_path()
115 + chk_cmd += 'OUT=$3\n'
115 chk_cmd += ' '.join(( 'java -jar $1', 116 chk_cmd += ' '.join(( 'java -jar $1',
116 - '-c $2', 117 + '-c $2',
117 - ' '.join(['%s/%s' % (base, s) for s in srcs]) )) 118 + ' '.join(['%s/%s' % (base, s) for s in srcs]) ))
118 - chk_cmd += ' | grep -E "^[^: ]*:\d+:\d+: error:"' 119 + chk_cmd += ' | tee $OUT'
120 + chk_cmd += ' | grep -E "^.*[0-9]+:[0-9]+: error:"'
119 chk_cmd += ' | sed "s#^.*%s/#%s:#g"\n' % (base, name) 121 chk_cmd += ' | sed "s#^.*%s/#%s:#g"\n' % (base, name)
120 - chk_cmd += 'test ${PIPESTATUS[0]} -eq 0\n' # status of java command 122 + chk_cmd += 'RESULT=(${PIPESTATUS[*]})\n' # RESULT[0] is checkstyle result, RESULT[2] is grep
123 + chk_cmd += 'test ${RESULT[2]} -eq 0 || cat $OUT\n'
124 + chk_cmd += 'rm $OUT\n'
125 + chk_cmd += 'exit ${RESULT[0]}'
121 126
122 genrule( 127 genrule(
123 name = name + '-checkstyle-sh', 128 name = name + '-checkstyle-sh',
...@@ -131,7 +136,8 @@ def osgi_jar( ...@@ -131,7 +136,8 @@ def osgi_jar(
131 test = ':' + name + '-checkstyle-sh', 136 test = ':' + name + '-checkstyle-sh',
132 args = [ 137 args = [
133 '$(location //lib:checkstyle)', 138 '$(location //lib:checkstyle)',
134 - '$(location //tools/build/conf:checkstyle-xml)' 139 + '$(location //tools/build/conf:checkstyle-xml)',
140 + '`mktemp /tmp/%s-checkstyle-XXXXXX`' % name,
135 ], 141 ],
136 deps = [ 142 deps = [
137 ':'+ bare_jar_name, 143 ':'+ bare_jar_name,
......