run-clang-tidy only display output on error

This commit is contained in:
Daniel Agar
2017-01-29 20:41:59 -05:00
parent 226148ea8b
commit 4e3b4091e8
4 changed files with 141 additions and 22 deletions
+16 -2
View File
@@ -46,6 +46,8 @@ import sys
import tempfile
import threading
tidy_failures = 0
def find_compilation_database(path):
"""Adjusts the directory until a compilation database is found."""
@@ -102,8 +104,15 @@ def run_tidy(args, tmpdir, build_path, queue):
invocation = get_tidy_invocation(name, args.clang_tidy_binary, args.checks,
tmpdir, build_path, args.header_filter,
args.extra_arg, args.extra_arg_before)
sys.stdout.write(' '.join(invocation) + '\n')
subprocess.call(invocation)
try:
subprocess.check_call(invocation, stdin=None, stdout=open(os.devnull, 'wb'), stderr=subprocess.STDOUT)
except subprocess.CalledProcessError, e:
sys.stdout.write(' '.join(invocation) + '\n')
subprocess.call(invocation)
global tidy_failures
tidy_failures = tidy_failures + 1
queue.task_done()
@@ -208,5 +217,10 @@ def main():
print 'Applying fixes ...'
apply_fixes(args, tmpdir)
global tidy_failures
if tidy_failures > 0:
print >>sys.stderr, "clang-tidy errors: ", tidy_failures
sys.exit(1)
if __name__ == '__main__':
main()