Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Make output of run_tests.py easier to understand. #16229

Merged
merged 1 commit into from
Jan 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions testing/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import re
import subprocess
import sys
import time

buildroot_dir = os.path.abspath(os.path.join(os.path.realpath(__file__), '..', '..', '..'))
out_dir = os.path.join(buildroot_dir, 'out')
Expand All @@ -24,12 +25,34 @@

fml_unittests_filter = '--gtest_filter=-*TimeSensitiveTest*'

def PrintDivider(char='='):
print '\n'
for _ in xrange(4):
print(''.join([char for _ in xrange(80)]))
print '\n'

def RunCmd(cmd, **kwargs):
try:
print(subprocess.check_output(cmd, **kwargs))
except subprocess.CalledProcessError as cpe:
print(cpe.output)
raise cpe
command_string = ' '.join(cmd)

PrintDivider('>')
print 'Running command "%s"' % command_string

start_time = time.time()
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kwargs)
(output, _) = process.communicate()
end_time = time.time()

# Print the result no matter what.
for line in output.splitlines():
print line

if process.returncode != 0:
PrintDivider('!')
raise Exception('Command "%s" exited with code %d' % (command_string, process.returncode))

PrintDivider('<')
print 'Command run successfully in %.2f seconds: %s' % (end_time - start_time, command_string)


def IsMac():
return sys.platform == 'darwin'
Expand Down