Skip to content

Commit bc701b2

Browse files
authored
Add --print_test_command to print actual test command (#95)
1 parent e06d5c8 commit bc701b2

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

gtest_parallel.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -355,17 +355,23 @@ def move_to(self, destination_dir, tasks):
355355
for task in tasks:
356356
shutil.move(task.log_file, destination_dir)
357357

358-
def print_tests(self, message, tasks, print_try_number):
358+
def print_tests(self, message, tasks, print_try_number, print_test_command):
359359
self.out.permanent_line("%s (%s/%s):" %
360360
(message, len(tasks), self.total_tasks))
361361
for task in sorted(tasks):
362362
runtime_ms = 'Interrupted'
363363
if task.runtime_ms is not None:
364364
runtime_ms = '%d ms' % task.runtime_ms
365-
self.out.permanent_line(
366-
"%11s: %s %s%s" %
367-
(runtime_ms, task.test_binary, task.test_name,
368-
(" (try #%d)" % task.execution_number) if print_try_number else ""))
365+
if print_test_command:
366+
self.out.permanent_line(
367+
"%11s: %s%s" %
368+
(runtime_ms, " ".join(task.test_command),
369+
(" (try #%d)" % task.execution_number) if print_try_number else ""))
370+
else:
371+
self.out.permanent_line(
372+
"%11s: %s %s%s" %
373+
(runtime_ms, task.test_binary, task.test_name,
374+
(" (try #%d)" % task.execution_number) if print_try_number else ""))
369375

370376
def log_exit(self, task):
371377
with self.stdout_lock:
@@ -795,6 +801,11 @@ def default_options_parser():
795801
action='store_true',
796802
default=False,
797803
help='list the run time of each test at the end of execution')
804+
parser.add_option(
805+
'--print_test_command',
806+
action='store_true',
807+
default=False,
808+
help='Print full test command instead of name')
798809
parser.add_option('--shard_count',
799810
type='int',
800811
default=1,
@@ -906,19 +917,19 @@ def main():
906917
if task_manager.passed:
907918
logger.move_to('passed', task_manager.passed)
908919
if options.print_test_times:
909-
logger.print_tests('PASSED TESTS', task_manager.passed, print_try_number)
920+
logger.print_tests('PASSED TESTS', task_manager.passed, print_try_number, options.print_test_command)
910921

911922
if task_manager.failed:
912-
logger.print_tests('FAILED TESTS', task_manager.failed, print_try_number)
923+
logger.print_tests('FAILED TESTS', task_manager.failed, print_try_number, options.print_test_command)
913924
logger.move_to('failed', task_manager.failed)
914925

915926
if task_manager.timed_out:
916-
logger.print_tests('TIMED OUT TESTS', task_manager.timed_out, print_try_number)
927+
logger.print_tests('TIMED OUT TESTS', task_manager.timed_out, print_try_number, options.print_test_command)
917928
logger.move_to('timed_out', task_manager.timed_out)
918929

919930
if task_manager.started:
920931
logger.print_tests('INTERRUPTED TESTS', task_manager.started.values(),
921-
print_try_number)
932+
print_try_number, options.print_test_command)
922933
logger.move_to('interrupted', task_manager.started.values())
923934

924935
if options.repeat > 1 and (task_manager.failed or task_manager.started):

0 commit comments

Comments
 (0)