windows: Fix two Windows-only gunittest failures - #7895
Open
echoix wants to merge 4 commits into
Open
Conversation
sortfile()'s in-memory fallback (used when the 'sort' command is unavailable, e.g. on Windows) converted every line to float without skipping empty ones, crashing on a trailing blank line with ValueError: could not convert string to float: ''. The main statistics loop already skips empty lines; apply the same handling here. Found and fixed with the help of Claude Code, using a Windows CI test report to diagnose the failure.
GISBASE itself (where the grass.bat launcher lives) is never added to PATH on Windows, only GISBASE\bin is, so the bare "grass.bat" name failed with FileNotFoundError when this test ran inside an existing GRASS session (as it does under grass.gunittest.main in CI). Resolve the launcher through GISBASE when it is set, keeping the bare name as a fallback otherwise. Root-caused with the help of Claude Code, by tracing the Windows OSGeo4W CI build scripts to see where the launcher batch file ends up and what gets added to PATH, and verified by reproducing and fixing the failure in a scratch Linux build with os.name patched to "nt".
Restores the known-limitation note dropped when the old TODO comments were replaced: the GISBASE-based executable resolution assumes a from-source build's grass.bat, but an OSGeo4W package install names the launcher with a version suffix (e.g. grass86.bat), so it isn't covered here.
echoix
force-pushed
the
claude/windows-test-failures-vh9fvw
branch
from
September 5, 2026 21:00
8f81fe8 to
e8d02d3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I'm preparing to enable running Windows tests in random order, and have launched 30+15 runs with that. But, some test fixes were made along the way. This PR is one of those such fixes, two small and simple fixes.
Description
Fixes two of the tests failing in the Windows OSGeo4W CI run (found by
downloading and inspecting the
testreport-windows-2022artifact from arecent
mainrun):scripts/db.univar/testsuite/test_db_univar.py::test_calculate_extended—db.univar.py'ssortfile()in-memory fallback (used when thesortcommand is unavailable, e.g. on Windows) converted every line to
floatwithout skipping empty ones, crashing on a trailing blank line with
ValueError: could not convert string to float: ''. The main statisticsloop a few lines above already skips empty lines;
sortfile()now doesthe same.
lib/init/testsuite/test_grass_tmp_mapset.py(all 4 tests, failing insetUp) —GISBASEitself (where thegrass.batlauncher lives in thisCI's from-source build) is never added to
PATHon Windows, onlyGISBASE\binis, so the bare"grass.bat"name raisedFileNotFoundError. There was already aTODOin the code acknowledgingthis. The executable is now resolved through
GISBASEwhen it is set.Motivation and context
These are 2 of 8 gunittest files failing in the Windows CI run; the other 6
are environment-specific issues (missing OpenGL on the headless runner, a
numpy repr version difference in a doctest, an access-violation crash, a
timing issue, an md5sum mismatch in a shell test, and an external addon
server returning 404) that aren't simple, isolated code fixes.
How has this been tested?
db.univar.pyfix was verified directly: reproduced the exact crash(
ValueError: could not convert string to float: '') against a file witha trailing blank CRLF line using the old code, then confirmed the fixed
version sorts the same input correctly.
test_grass_tmp_mapset.pyfix was verified end-to-end on a scratchCMake build of GRASS on Linux, with
os.namepatched to"nt"so theWindows branch actually executes: reproduced the original
FileNotFoundErrorwith the pre-fix code inside a live GRASS session,then confirmed the fixed code resolves the launcher through
GISBASEandall 4 tests pass.
grass-devOSGeo4W nightly package instead of compiling from source (withdb.univar.pypatched post-install, since the nightly package predatesthis fix), to see how these fixes hold up against a real packaged
install rather than this CI's from-source build. Confirmed the
db.univarfix passes there too, buttest_grass_tmp_mapset.pyfailsdifferently: a real package puts the launcher at
OSGEO4W_ROOT\bin, notinside
GISBASE, so theGISBASE-based resolution added here doesn'tgeneralize to that layout. This matches how this CI job actually builds
GRASS (from source, not from a package), so the fix as written is correct
for it, but it's worth flagging as a known limitation if a package-based
install is ever used instead.
Screenshots (if appropriate)
N/A
Types of changes
functionality to not work as before)
Checklist
pre-defined prefixes
of this project.
Large use of AI (Claude Code) was used to investigate the CI failures,
diagnose root causes, and write and verify these fixes.