@@ -335,16 +335,16 @@ def __init__(self, *, failfast: bool, report_durations: int | None):
335
335
self .total_duration = 0.0
336
336
337
337
@staticmethod
338
- def report_start (test_id : TestId ):
339
- log (f"{ test_id } ... " , incomplete = True )
338
+ def report_start (test_id : TestId , prefix = '' ):
339
+ log (f"{ prefix } { test_id } ... " , incomplete = True )
340
340
341
- def report_result (self , result : TestResult ):
341
+ def report_result (self , result : TestResult , prefix = '' ):
342
342
self .results .append (result )
343
343
message = f"{ result .test_id } ... { result .status } "
344
344
if result .status == TestStatus .SKIPPED and result .param :
345
- message = f"{ message } { result .param !r} "
345
+ message = f"{ prefix } { message } { result .param !r} "
346
346
else :
347
- message = f"{ message } ({ result .duration :.2f} s)"
347
+ message = f"{ prefix } { message } ({ result .duration :.2f} s)"
348
348
log (message )
349
349
350
350
def tests_failed (self ):
@@ -532,10 +532,10 @@ def __init__(self, *, num_processes, subprocess_args, separate_workers, timeout_
532
532
self .crashes = []
533
533
self .default_test_timeout = 600
534
534
535
- def report_result (self , result : TestResult ):
535
+ def report_result (self , result : TestResult , prefix = '' ):
536
536
if self .failfast and result .status in FAILED_STATES :
537
537
self .stop_event .set ()
538
- super ().report_result (result )
538
+ super ().report_result (result , prefix = prefix )
539
539
540
540
def tests_failed (self ):
541
541
return super ().tests_failed () or bool (self .crashes )
@@ -608,7 +608,7 @@ def run_tests(self, tests: list['TestSuite']):
608
608
log (crash )
609
609
610
610
def run_partitions_in_subprocesses (self , executor , partitions : list [list ['Test' ]]):
611
- workers = [SubprocessWorker (self , partition ) for i , partition in enumerate (partitions )]
611
+ workers = [SubprocessWorker (i , self , partition ) for i , partition in enumerate (partitions )]
612
612
futures = [executor .submit (worker .run_in_subprocess_and_watch ) for worker in workers ]
613
613
614
614
def dump_worker_status ():
@@ -652,7 +652,8 @@ def sigterm_handler(_signum, _frame):
652
652
653
653
654
654
class SubprocessWorker :
655
- def __init__ (self , runner : ParallelTestRunner , tests : list ['Test' ]):
655
+ def __init__ (self , worker_id : int , runner : ParallelTestRunner , tests : list ['Test' ]):
656
+ self .prefix = f'[worker-{ worker_id + 1 } ] '
656
657
self .runner = runner
657
658
self .stop_event = runner .stop_event
658
659
self .lock = threading .RLock ()
@@ -675,7 +676,7 @@ def process_event(self, event):
675
676
except ValueError :
676
677
# It executed something we didn't ask for. Not sure why this happens
677
678
log (f'WARNING: unexpected test started { test_id } ' )
678
- self .runner .report_start (test_id )
679
+ self .runner .report_start (test_id , prefix = self . prefix )
679
680
with self .lock :
680
681
self .last_started_test_id = test_id
681
682
self .last_started_time = time .time ()
@@ -694,7 +695,7 @@ def process_event(self, event):
694
695
output = test_output ,
695
696
duration = event .get ('duration' ),
696
697
)
697
- self .runner .report_result (result )
698
+ self .runner .report_result (result , prefix = self . prefix )
698
699
with self .lock :
699
700
self .last_started_test_id = None
700
701
self .last_started_time = time .time () # Starts timeout for the following teardown/setup
@@ -846,7 +847,7 @@ def run_in_subprocess_and_watch(self):
846
847
param = message ,
847
848
output = output ,
848
849
duration = (time .time () - self .last_started_time ),
849
- ))
850
+ ), prefix = self . prefix )
850
851
if blame_id is not self .last_started_test_id :
851
852
# If we're here, it means we didn't know exactly which test we were executing, we were
852
853
# somewhere in between
@@ -1332,15 +1333,15 @@ def main_extract_test_timings(args):
1332
1333
1333
1334
# Download the log file
1334
1335
with urllib .request .urlopen (args .url ) as response :
1335
- log = response .read ().decode ("utf-8" , errors = "replace" )
1336
+ log_content = response .read ().decode ("utf-8" , errors = "replace" )
1336
1337
1337
1338
pattern = re .compile (
1338
1339
r"^(?P<path>[^\s:]+)::\S+ +\.\.\. (?:ok|FAIL|ERROR|SKIPPED|expected failure|unexpected success|\S+) \((?P<time>[\d.]+)s\)" ,
1339
1340
re .MULTILINE ,
1340
1341
)
1341
1342
1342
1343
timings = {}
1343
- for match in pattern .finditer (log ):
1344
+ for match in pattern .finditer (log_content ):
1344
1345
raw_path = match .group ("path" ).replace ("\\ " , "/" )
1345
1346
t = float (match .group ("time" ))
1346
1347
timings .setdefault (raw_path , 0.0 )
0 commit comments