From 90394ecdfb923dfdf380c112b526de9cb8379939 Mon Sep 17 00:00:00 2001 From: roman Date: Thu, 1 Oct 2026 15:41:37 +0300 Subject: [PATCH] fix: finish test_isolated cleanup on Ctrl+C uv run forwards SIGINT to the child that already got it from the process group, so the second KeyboardInterrupt aborted the cleanup and left the test container and database behind. Run the script with $(PYTHON) like the skeleton checks and ignore SIGINT during cleanup. Co-Authored-By: Claude Opus 5.5 --- Makefile | 5 +++-- student-tests/run_isolated.py | 9 +++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index e3354ae6..58dc0566 100644 --- a/Makefile +++ b/Makefile @@ -166,10 +166,11 @@ student_test: # образ на временной базе test_: сборка, миграции, отдельный # контейнер api на 127.0.0.1:TEST_APP_PORT, make test и make student_test, -# затем уборка при любом исходе. KEEP_TEST_DB=1 оставляет базу для разбора +# затем уборка при любом исходе. KEEP_TEST_DB=1 оставляет базу для разбора. +# $(PYTHON), а не uv run: uv повторно шлёт SIGINT, и Ctrl+C обрывал уборку .PHONY: test_isolated test_isolated: env_setup start_db - uv run python student-tests/run_isolated.py $(if $(KEEP_TEST_DB),--keep-db,) + $(PYTHON) student-tests/run_isolated.py $(if $(KEEP_TEST_DB),--keep-db,) .PHONY: lint lint: diff --git a/student-tests/run_isolated.py b/student-tests/run_isolated.py index 0b0b575f..3466d274 100644 --- a/student-tests/run_isolated.py +++ b/student-tests/run_isolated.py @@ -7,11 +7,18 @@ в том числе по Ctrl+C. Рабочая база и рабочий контейнер API не трогаются. Только stdlib: всё через docker compose и make. Решение 12 design change `postgres-storage`. + +Запускается напрямую `$(PYTHON)`, как проверки skeleton, а не через +`uv run`: uv пересылает SIGINT дочернему процессу, хотя тот уже получил +его от группы процессов, и второй `KeyboardInterrupt` обрывал уборку. """ +from __future__ import annotations + import argparse import json import re +import signal import subprocess import sys import time @@ -194,6 +201,8 @@ def main() -> int: say(f"setup failed: {e}") results["setup"] = 1 finally: + # повторный Ctrl+C не должен оборвать уборку на полпути + signal.signal(signal.SIGINT, signal.SIG_IGN) if failed: say(f"last {LOG_TAIL_LINES} lines of {container}") run(