Handle completion of a single test process Args: proc_state: State information for the completed process active_processes: List of currently active processes completed_timings: List to collect timing data last_activity_time: Dictionary tracking activity time
(
proc_state: ProcessState,
active_processes: list[RunningProcess],
completed_timings: list[ProcessTiming],
last_activity_time: dict[RunningProcess, float],
)
| 1114 | |
| 1115 | |
| 1116 | def _handle_process_completion( |
| 1117 | proc_state: ProcessState, |
| 1118 | active_processes: list[RunningProcess], |
| 1119 | completed_timings: list[ProcessTiming], |
| 1120 | last_activity_time: dict[RunningProcess, float], |
| 1121 | ) -> None: |
| 1122 | """ |
| 1123 | Handle completion of a single test process |
| 1124 | |
| 1125 | Args: |
| 1126 | proc_state: State information for the completed process |
| 1127 | active_processes: List of currently active processes |
| 1128 | completed_timings: List to collect timing data |
| 1129 | last_activity_time: Dictionary tracking activity times |
| 1130 | |
| 1131 | Raises: |
| 1132 | TestExecutionFailedException: If process failed |
| 1133 | """ |
| 1134 | proc = proc_state.process |
| 1135 | cmd = proc_state.command |
| 1136 | if isinstance(cmd, list): |
| 1137 | cmd = subprocess.list2cmdline(cmd) |
| 1138 | |
| 1139 | try: |
| 1140 | returncode = proc.wait() |
| 1141 | if returncode != 0: |
| 1142 | test_name = _extract_test_name(cmd) |
| 1143 | ts_print(f"\nCommand failed: {cmd} with return code {returncode}") |
| 1144 | ts_print("\033[91m###### ERROR ######\033[0m") |
| 1145 | ts_print(f"Test failed: {test_name}") |
| 1146 | |
| 1147 | # Capture the actual output from the failed process |
| 1148 | try: |
| 1149 | actual_output = proc.stdout |
| 1150 | if actual_output.strip(): |
| 1151 | ts_print("\n=== ACTUAL OUTPUT FROM FAILED PROCESS ===") |
| 1152 | ts_print(actual_output) |
| 1153 | ts_print("=== END OF OUTPUT ===") |
| 1154 | else: |
| 1155 | actual_output = "No output captured from failed process" |
| 1156 | except KeyboardInterrupt as ki: |
| 1157 | handle_keyboard_interrupt(ki) |
| 1158 | raise |
| 1159 | except Exception as e: |
| 1160 | actual_output = f"Error capturing output: {e}" |
| 1161 | |
| 1162 | # Flush output for real-time visibility (but avoid on Windows due to blocking issues) |
| 1163 | if os.name != "nt": # Only flush on non-Windows systems |
| 1164 | sys.stdout.flush() |
| 1165 | for p in active_processes: |
| 1166 | if p != proc: |
| 1167 | p.kill() |
| 1168 | failure = TestFailureInfo( |
| 1169 | test_name=test_name, |
| 1170 | command=str(cmd), |
| 1171 | return_code=returncode, |
| 1172 | output=actual_output, |
| 1173 | error_type="command_failure", |
nothing calls this directly
no test coverage detected