test.py: Return test output only if subprocess succeeded

The current code will try to print the output of a
subprocess.Popen().communicate() call even if that
call raised an exception and that output is None.

Let's fix this problem by only printing the output
if it's not None.

Signed-off-by: Lucas Meneghel Rodrigues <lmr@scylladb.com>
This commit is contained in:
Lucas Meneghel Rodrigues
2015-10-27 11:15:30 -02:00
committed by Avi Kivity
parent 5cdbc3701a
commit 42c0acfc44

View File

@@ -149,9 +149,10 @@ if __name__ == "__main__":
print_status('TIMED OUT\n')
else:
print_status(' with error code {code}\n'.format(code=proc.returncode))
print('=== stdout START ===')
print(str(out, encoding='UTF-8'))
print('=== stdout END ===')
if out is not None:
print('=== stdout START ===')
print(str(out, encoding='UTF-8'))
print('=== stdout END ===')
all_ok = False
else:
print_status('%s PASSED %s' % (prefix, path))