2222from .single import PROGRESS_MIN_TIME
2323from .utils import (
2424 StrPath , TestName , MS_WINDOWS ,
25- format_duration , print_warning , count , plural )
25+ format_duration , print_warning , count , plural , get_signal_name )
2626from .worker import create_worker_process , USE_PROCESS_GROUP
2727
2828if MS_WINDOWS :
@@ -92,7 +92,7 @@ def __init__(self,
9292 test_name : TestName ,
9393 err_msg : str | None ,
9494 stdout : str | None ,
95- state : str = State . MULTIPROCESSING_ERROR ):
95+ state : str ):
9696 result = TestResult (test_name , state = state )
9797 self .mp_result = MultiprocessResult (result , stdout , err_msg )
9898 super ().__init__ ()
@@ -298,7 +298,9 @@ def read_stdout(self, stdout_file: TextIO) -> str:
298298 # gh-101634: Catch UnicodeDecodeError if stdout cannot be
299299 # decoded from encoding
300300 raise WorkerError (self .test_name ,
301- f"Cannot read process stdout: { exc } " , None )
301+ f"Cannot read process stdout: { exc } " ,
302+ stdout = None ,
303+ state = State .WORKER_BUG )
302304
303305 def read_json (self , json_file : JsonFile , json_tmpfile : TextIO | None ,
304306 stdout : str ) -> tuple [TestResult , str ]:
@@ -317,10 +319,11 @@ def read_json(self, json_file: JsonFile, json_tmpfile: TextIO | None,
317319 # decoded from encoding
318320 err_msg = f"Failed to read worker process JSON: { exc } "
319321 raise WorkerError (self .test_name , err_msg , stdout ,
320- state = State .MULTIPROCESSING_ERROR )
322+ state = State .WORKER_BUG )
321323
322324 if not worker_json :
323- raise WorkerError (self .test_name , "empty JSON" , stdout )
325+ raise WorkerError (self .test_name , "empty JSON" , stdout ,
326+ state = State .WORKER_BUG )
324327
325328 try :
326329 result = TestResult .from_json (worker_json )
@@ -329,7 +332,7 @@ def read_json(self, json_file: JsonFile, json_tmpfile: TextIO | None,
329332 # decoded from encoding
330333 err_msg = f"Failed to parse worker process JSON: { exc } "
331334 raise WorkerError (self .test_name , err_msg , stdout ,
332- state = State .MULTIPROCESSING_ERROR )
335+ state = State .WORKER_BUG )
333336
334337 return (result , stdout )
335338
@@ -345,9 +348,15 @@ def _runtest(self, test_name: TestName) -> MultiprocessResult:
345348 stdout = self .read_stdout (stdout_file )
346349
347350 if retcode is None :
348- raise WorkerError (self .test_name , None , stdout , state = State .TIMEOUT )
351+ raise WorkerError (self .test_name , stdout = stdout ,
352+ err_msg = None ,
353+ state = State .TIMEOUT )
349354 if retcode != 0 :
350- raise WorkerError (self .test_name , f"Exit code { retcode } " , stdout )
355+ name = get_signal_name (retcode )
356+ if name :
357+ retcode = f"{ retcode } ({ name } )"
358+ raise WorkerError (self .test_name , f"Exit code { retcode } " , stdout ,
359+ state = State .WORKER_FAILED )
351360
352361 result , stdout = self .read_json (json_file , json_tmpfile , stdout )
353362
@@ -527,7 +536,7 @@ def display_result(self, mp_result: MultiprocessResult) -> None:
527536
528537 text = str (result )
529538 if mp_result .err_msg :
530- # MULTIPROCESSING_ERROR
539+ # WORKER_BUG
531540 text += ' (%s)' % mp_result .err_msg
532541 elif (result .duration >= PROGRESS_MIN_TIME and not pgo ):
533542 text += ' (%s)' % format_duration (result .duration )
@@ -543,7 +552,7 @@ def _process_result(self, item: QueueOutput) -> TestResult:
543552 # Thread got an exception
544553 format_exc = item [1 ]
545554 print_warning (f"regrtest worker thread failed: { format_exc } " )
546- result = TestResult ("<regrtest worker>" , state = State .MULTIPROCESSING_ERROR )
555+ result = TestResult ("<regrtest worker>" , state = State .WORKER_BUG )
547556 self .results .accumulate_result (result , self .runtests )
548557 return result
549558
0 commit comments