From 39d0646871f0fec67407c96d617ed87d44251945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sat, 26 Sep 2026 11:01:20 -0400 Subject: [PATCH] CI: Test pytest --capture=no to isolate fd-level output capturing (not for merge) A plain `python -c "from grass.pygrass import utils"` succeeds even after pip has installed pytest/xdist/timeout/randomly (see ci-diag/standalone-import-after-pip), but pytest itself collecting the same import crashes with "Windows fatal exception: code 0xc0000139" regardless of xdist (ci-diag/no-xdist-single-process) or the exe launcher stub (ci-diag/python-m-pytest-vs-exe). pytest-timeout's watchdog thread (pytest_runtest_protocol) does not start until after a test item is successfully collected, per its own source, so it isn't running yet when this crash happens during collection -- ruling that out too. The other big process-wide difference between a plain python invocation and a pytest run: pytest's default fd-level output capturing (dup2-based stdout/stderr redirection), active for the entire session including collection, before any test file is even imported. This tests whether --capture=no (disabling it) avoids the crash. Temporary, for CI investigation only. Co-Authored-By: Claude Sonnet 5 --- .github/workflows/osgeo4w.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/osgeo4w.yml b/.github/workflows/osgeo4w.yml index 96b5a6bb9aa..07387f29437 100644 --- a/.github/workflows/osgeo4w.yml +++ b/.github/workflows/osgeo4w.yml @@ -133,6 +133,29 @@ jobs: pytest-randomly # Obfuscated usage of GitHub Actions features, Windows CMD shell limits analysis shell: cmd /D /E:ON /V:OFF /S /C "CALL C:/OSGeo4W/OSGeo4W.bat "{0}"" # zizmor: ignore[misfeature] + + - name: "[CI diagnostic, not for merge] pytest with --capture=no" + # A plain `python -c "from grass.pygrass import utils"` succeeds + # even AFTER pip has installed pytest/xdist/timeout/randomly + # (see ci-diag/standalone-import-after-pip), but pytest itself + # collecting the same import crashes with "Windows fatal + # exception: code 0xc0000139" regardless of xdist, the exe + # launcher stub, or pytest-timeout (whose watchdog thread does + # not start until after collection succeeds, per its own + # source, so it isn't running yet when this crash happens). + # pytest's other big process-wide difference from a plain + # python invocation is its default fd-level output capturing + # (dup2-based stdout/stderr redirection), active for the whole + # session including collection. This tests whether disabling + # it with --capture=no avoids the crash. + run: | + call %OSGEO4W_ROOT%\opt\grass\etc\env.bat + set PYTHONPATH=%GISBASE%\etc\python;%PYTHONPATH% + path %GISBASE%\lib;%GISBASE%\bin;%PATH% + pytest -v --capture=no imagery/i.gensig/testsuite/test_i_gensig.py lib/arraystats/tests + # Obfuscated usage of GitHub Actions features, Windows CMD shell limits analysis + shell: cmd /D /E:ON /V:OFF /S /C "CALL C:/OSGeo4W/OSGeo4W.bat "{0}"" # zizmor: ignore[misfeature] + - name: Run pytest with multiple workers in parallel run: | call %OSGEO4W_ROOT%\opt\grass\etc\env.bat