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: