Skip to content

Commit a06283d

Browse files
chinmaygardestuartmorgan-g
authored andcommitted
Make output of run_tests.py easier to understand. (flutter#16229)
* The outputs of all commands are not printed and not just commands that fail. * The stdout and stderr are now printed in order. * Clear dividers mark logs from specific subprocesses or errors. * The test whose run failed should now be exactly on top of the error message and code.
1 parent 8768280 commit a06283d

File tree

1 file changed

+28
-5
lines changed

1 file changed

+28
-5
lines changed

testing/run_tests.py

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import re
1414
import subprocess
1515
import sys
16+
import time
1617

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

2526
fml_unittests_filter = '--gtest_filter=-*TimeSensitiveTest*'
2627

28+
def PrintDivider(char='='):
29+
print '\n'
30+
for _ in xrange(4):
31+
print(''.join([char for _ in xrange(80)]))
32+
print '\n'
33+
2734
def RunCmd(cmd, **kwargs):
28-
try:
29-
print(subprocess.check_output(cmd, **kwargs))
30-
except subprocess.CalledProcessError as cpe:
31-
print(cpe.output)
32-
raise cpe
35+
command_string = ' '.join(cmd)
36+
37+
PrintDivider('>')
38+
print 'Running command "%s"' % command_string
39+
40+
start_time = time.time()
41+
process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, **kwargs)
42+
(output, _) = process.communicate()
43+
end_time = time.time()
44+
45+
# Print the result no matter what.
46+
for line in output.splitlines():
47+
print line
48+
49+
if process.returncode != 0:
50+
PrintDivider('!')
51+
raise Exception('Command "%s" exited with code %d' % (command_string, process.returncode))
52+
53+
PrintDivider('<')
54+
print 'Command run successfully in %.2f seconds: %s' % (end_time - start_time, command_string)
55+
3356

3457
def IsMac():
3558
return sys.platform == 'darwin'

0 commit comments

Comments
 (0)