From 0d1749a2716880b48e65e35fad0573fa98cb31d4 Mon Sep 17 00:00:00 2001 From: Kelbo Date: Mon, 30 Nov 2026 23:43:45 -0500 Subject: [PATCH] tests: copy every local import of the debug launcher into the run.ps1 control The real_log_error control copies debug_launch.py plus a hard-coded list of local modules into a scratch tree. #3674 (58352a682) added 'from stall_watch import StallWatch' to debug_launch.py and did not update that list, so the copied launcher died with ModuleNotFoundError before reaching the events.txt open. The control then reported that the debugger log error was not captured, because the summary held the missing module instead of the PermissionError it looks for. Derive the list from debug_launch.py's own imports so the next addition cannot break the control the same way. --- tests/startup_run_ps1_check.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/startup_run_ps1_check.py b/tests/startup_run_ps1_check.py index 69e2533996..e433579fd7 100644 --- a/tests/startup_run_ps1_check.py +++ b/tests/startup_run_ps1_check.py @@ -165,7 +165,13 @@ def run_case(shell, script, code, work, translate=False, switches=(), passed=(), startup.mkdir(parents=True) (startup / "run.ps1").write_bytes(script.encode("utf-8")) if real_log_error: - for name in ("debug_launch.py", "launch.py", "host_cpu.py", "hook_window.py", "window_capture.py"): + # Copy the real debugger and every local module it imports. A hard-coded list turns each new + # import into a ModuleNotFoundError here, which is how #3674 broke this control: the summary + # then reports the missing module instead of the error the case is about. + source = (RUN_PS1.parent / "debug_launch.py").read_text(encoding="utf-8") + local = {f"{name}.py" for name in re.findall(r"^(?:from|import)\s+([A-Za-z_]\w*)", source, re.M) + if (RUN_PS1.parent / f"{name}.py").is_file()} + for name in sorted(local | {"debug_launch.py"}): shutil.copyfile(RUN_PS1.parent / name, startup / name) else: (startup / "debug_launch.py").write_text(STUB.format(code=code, early_exit=early_exit, emit_stderr=emit_stderr), encoding="utf-8")