From 122db2ed82b9e4ac3dad2c5ca6a80e276eab49df Mon Sep 17 00:00:00 2001 From: josch Date: Sat, 20 Sep 2014 14:39:24 +0200 Subject: [PATCH] tests/iwyu.py: print diff if descrepancy is found --- tests/iwyu.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/iwyu.py b/tests/iwyu.py index e25398e..43cb23f 100755 --- a/tests/iwyu.py +++ b/tests/iwyu.py @@ -4,18 +4,23 @@ from __future__ import print_function import json import subprocess +import shlex with open("compile_commands.json", "r") as f: tunits = json.load(f) result = 0 for tu in tunits: - _,rest = tu["command"].split(" ",1) + _,cmd = tu["command"].split(" ",1) + cmd = "%s %s"%("iwyu", cmd) + cmd = shlex.split(cmd) # iwyu does not distinguish between different outcomes of its check # so instead, we grep its stderr output # see http://code.google.com/p/include-what-you-use/issues/detail?id=157 - ret = subprocess.call("%s %s 2>&1 | grep \"has correct #\""%("iwyu", rest), shell=True) - if ret != 0: + ret = subprocess.Popen(cmd, stderr=subprocess.PIPE) + _,ret = ret.communicate() + if "has correct #" not in ret: result += 1 + print(ret) exit(result)