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 <noreply@anthropic.com>
This commit is contained in:
2026-10-01 15:41:37 +03:00
co-authored by Claude Opus 5.5
parent 4921afa39d
commit 90394ecdfb
2 changed files with 12 additions and 2 deletions
+3 -2
View File
@@ -166,10 +166,11 @@ student_test:
# образ на временной базе test_<POSTGRES_DB>: сборка, миграции, отдельный
# контейнер 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:
+9
View File
@@ -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(