fix(test): open .test files in binary mode to fix Windows e2e_test runner - #773
fix(test): open .test files in binary mode to fix Windows e2e_test runner#773chiangchenghsin-hash wants to merge 4 commits into
Conversation
…nner In MSVC text mode, getline() over LF-only files advances the stream position one extra byte per line (treating \n as \r\n internally). This makes setCursorToPreviousLine() re-read from a wrong offset, causing subsequent statements to be parsed as garbage (e.g. ";" or other single characters from wrong file positions). The fix opens the file in binary mode so tellg/seekg offsets match actual byte positions. CRLF line endings are handled by stripping trailing '\r' in nextLine() (separate change in test_parser.h). Verified on Windows 11 x64 MSVC with upstream louvain (6 tests), page_rank (1 test), and new Leiden (4 tests) — all 11 pass.
The previous commit accidentally only contained the openFile() function. This restores the complete file with the binary mode fix applied.
…lity When files are opened in binary mode (to fix Windows tellg/seekg offset issues), getline preserves the \\r from CRLF line endings. This adds a simple strip of trailing \\r in nextLine() so both LF and CRLF test files are parsed identically on all platforms. Companion to the binary mode fix in test_parser.cpp.
|
Windows tests run every night (but not on every PR). They seem to be passing. https://github.com/LadybugDB/ladybug/actions/runs/30789230797/job/91609180138 |
|
Good point — the nightly Windows CI runs The So the nightly Windows tests pass because they never exercise the That said, the fix is harmless on Linux/macOS too (binary mode + strip |
|
To be more precise with evidence — here's exactly what the Windows CI step runs ( if [ "$RUNNER_OS" = "Windows" ]; then
make test-build-release
ctest --test-dir build/release/test --output-on-failure -j "${TEST_JOBS}"
exit # ← exits here, never reaches the e2e_test path
fiAnd the minimal-linux-extension-test:
runs-on: ubuntu-latest # ← Linux only
if: ${{ github.event_name != 'workflow_dispatch' || github.event.inputs.platform == 'linux' }}So on Windows, The specific failure mode: when If you'd like, I can add a Windows extension test step to the CI workflow as a follow-up PR. |
|
For concrete evidence, here's the actual failure output I captured while debugging on Windows 11 x64 MSVC 19.50: The The root cause: MSVC text mode All 11 upstream |
Summary
Fixes the Windows e2e_test runner which has never worked on MSVC — all
.testfiles fail to parse on Windows due to atellg()/seekg()offset bug in text mode.Root Cause
MSVC's text mode (
ifstream::open(path)) adds an internal\r\n → \ntranslation layer. Whengetline()reads an LF-only file,tellg()returns a position that is 1 byte ahead per line (treating\nas the second byte of a\r\npair). AfterextractTextBeforeNextStatement()callssetCursorToPreviousLine()→seekg(previousFilePosition), the nextgetline()reads from a wrong byte offset, causing subsequent statements to be parsed as garbage characters (e.g.,";"instead of"---- ok").Fix (2 files, 10 lines)
test/test_runner/test_parser.cppBinary mode makes
tellg()/seekg()work with exact byte positions on all platforms.test/include/test_runner/test_parser.hVerification
Tested on Windows 11 x64 MSVC 19.50 with 11 upstream algo e2e tests:
Before fix: All tests threw
Invalid statementon the first multi-lineCREATEstatement.After fix: 11/11 pass, identical behavior to Linux.
Impact
\ris a no-op when files have LF endings).testfiles work as-is