From 514bead08bf343b4e57d85d82775a0aca725fcb1 Mon Sep 17 00:00:00 2001 From: Shlomi Livne Date: Wed, 18 Mar 2015 16:27:38 +0200 Subject: [PATCH] tests: Fix output bug in test.py The change to add a timeout to test.py introduced a bug that caused thestdout,stderr not to be printed in case of an error. This patch fixes this bug. Signed-off-by: Shlomi Livne --- test.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/test.py b/test.py index 29e1116691..2ae8456f78 100755 --- a/test.py +++ b/test.py @@ -105,6 +105,8 @@ if __name__ == "__main__": path = path + " --output_format=XML --log_level=all --report_level=no" proc = subprocess.Popen(path.split(' '), stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env,preexec_fn=os.setsid) signal.alarm(args.timeout) + out = None + err = None try: out, err = proc.communicate() signal.alarm(0) @@ -112,21 +114,22 @@ if __name__ == "__main__": os.killpg(os.getpgid(proc.pid), signal.SIGKILL) proc.kill() proc.returncode = -1 - if proc.returncode: - print_status('FAILED: %s\n' % (path)) - if proc.returncode == -1: - print_status('TIMED OUT\n') - if out: - print('=== stdout START ===') - print(out.decode()) - print('=== stdout END ===') - if err: - print('=== stderr START ===') - print(err.decode()) - print('=== stderr END ===') - all_ok = False - else: - print_status('%s PASSED %s' % (prefix, path)) + finally: + if proc.returncode: + print_status('FAILED: %s\n' % (path)) + if proc.returncode == -1: + print_status('TIMED OUT\n') + if out: + print('=== stdout START ===') + print(out.decode()) + print('=== stdout END ===') + if err: + print('=== stderr START ===') + print(err.decode()) + print('=== stderr END ===') + all_ok = False + else: + print_status('%s PASSED %s' % (prefix, path)) if args.jenkins and test[1] == 'boost': # remove the and jenkins_boost_log.write(out[9:-10])