From ba9e37c40e70521255cca4f8d1a44426dfffe0ea Mon Sep 17 00:00:00 2001 From: Pierre Raybaut <1311787+PierreRaybaut@users.noreply.github.com> Date: Tue, 20 Oct 2026 15:20:42 +0200 Subject: [PATCH] test(ci): report crashes of the test process A test process crash left no Python traceback in the CI logs: the DataLab application context redirected faulthandler to a log file kept on the runner, then disabled it, including pytest's own handler, for all subsequent tests. Tests now keep pytest's faulthandler, so that crash tracebacks are reported in the test output. The PyQt5 workflow also keeps the core dump of a crashed test process and prints its native backtrace. Assisted-by: Claude Opus 5.5 --- .github/workflows/test_pyqt5.yml | 22 +++++++++++++++++++++- datalab/tests/conftest.py | 3 +++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_pyqt5.yml b/.github/workflows/test_pyqt5.yml index cfb5a2d79..725a19119 100644 --- a/.github/workflows/test_pyqt5.yml +++ b/.github/workflows/test_pyqt5.yml @@ -117,7 +117,27 @@ jobs: - name: Lint with Ruff run: ruff check --output-format=github datalab - name: Test with pytest - run: pytest -v --tb=long + run: | + # Keep the core dump of a crashed test process, for the backtrace step below + sudo mkdir -p /tmp/cores && sudo chmod 1777 /tmp/cores || true + sudo sysctl -q -w kernel.core_pattern=/tmp/cores/core.%p || true + ulimit -c unlimited || true + pytest -v --tb=long + - name: Native backtrace of crashed test process + if: failure() + run: | + shopt -s nullglob + cores=(/tmp/cores/core.*) + if [ ${#cores[@]} -eq 0 ]; then + echo "No core dump found" + exit 0 + fi + sudo apt-get install -y gdb + python_exe="$(python -c 'import sys; print(sys.executable)')" + for core in "${cores[@]}"; do + echo "===== Backtrace of $core" + gdb -batch -ex "thread apply all bt 50" "$python_exe" "$core" + done build_latest: if: ${{ github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && (github.event.inputs.job_to_run == 'all' || github.event.inputs.job_to_run == 'build_latest')) }} diff --git a/datalab/tests/conftest.py b/datalab/tests/conftest.py index baf39f9aa..065c1dd90 100644 --- a/datalab/tests/conftest.py +++ b/datalab/tests/conftest.py @@ -47,6 +47,9 @@ def reset_datalab_configuration(): ensure_initialized(load_user_config=False) reset_to_defaults() Conf.rpc_server_enabled.set(False) + # Keep pytest's faulthandler, which reports crashes in the test output: the + # application context would redirect it to a log file, then disable it + Conf.faulthandler_enabled.set(False) try: yield finally: