Skip to content

Commit 36fbc47

Browse files
committed
add support for {#} similar to parallel
allows for `--gtest_output=xml:reports/report_{#}.xml` to be used instead of relying on googletest itself to lock a unique filename and using that Signed-off-by: Christopher Degawa <ccom@randomderp.com>
1 parent e28fc0e commit 36fbc47

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

gtest_parallel.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
# or a subprocess, including the one the current call is waiting for),
5555
# wait(p) will call p.terminate() and raise ProcessWasInterrupted.
5656
class SigintHandler(object):
57+
5758
class ProcessWasInterrupted(Exception):
5859
pass
5960

@@ -124,6 +125,7 @@ def term_width(out):
124125
# use this to ensure that lots of unimportant info (tests passing)
125126
# won't drown out important info (tests failing).
126127
class Outputter(object):
128+
127129
def __init__(self, out_file):
128130
self.__out_file = out_file
129131
self.__previous_line_was_transient = False
@@ -319,6 +321,7 @@ def run_task(self, task):
319321

320322

321323
class FilterFormat(object):
324+
322325
def __init__(self, output_dir):
323326
if sys.stdout.isatty():
324327
# stdout needs to be unbuffered since the output is interactive.
@@ -438,6 +441,7 @@ def flush(self):
438441

439442

440443
class CollectTestResults(object):
444+
441445
def __init__(self, json_dump_filepath):
442446
self.test_results_lock = threading.Lock()
443447
self.json_dump_file = open(json_dump_filepath, 'w')
@@ -485,7 +489,9 @@ def dump_to_file_and_close(self):
485489

486490
# Record of test runtimes. Has built-in locking.
487491
class TestTimes(object):
492+
488493
class LockedFile(object):
494+
489495
def __init__(self, filename, mode):
490496
self._filename = filename
491497
self._mode = mode
@@ -650,7 +656,8 @@ def find_tests(binaries, additional_args, options, times):
650656
if options.failed and last_execution_time is not None:
651657
continue
652658

653-
test_command = command + ['--gtest_filter=' + test_name]
659+
test_command = [a.replace('{#}', f"{test_count}")
660+
for a in command] + ['--gtest_filter=' + test_name]
654661
if (test_count - options.shard_index) % options.shard_count == 0:
655662
for execution_number in range(options.repeat):
656663
tasks.append(
@@ -666,7 +673,9 @@ def find_tests(binaries, additional_args, options, times):
666673

667674
def execute_tasks(tasks, pool_size, task_manager, timeout_seconds,
668675
serialize_test_cases):
676+
669677
class WorkerFn(object):
678+
670679
def __init__(self, tasks, running_groups):
671680
self.tasks = tasks
672681
self.running_groups = running_groups

0 commit comments

Comments
 (0)