Repository navigation
fix(desktop): make the backend test suite pass on Windows - #596
Merged
Merged
Conversation
Running the desktop backend suite on Windows failed 26 tests. Each was a latent platform assumption rather than an environment quirk, and two were real product bugs the tests only caught on Windows: - \set_modified\ on a read-only handle raises ACCESS_DENIED on Windows (FILE_WRITE_ATTRIBUTES); open for writing instead. This accounted for 20 failures across git_review and shadow_review. - \ econcile_thread_workspace\ compared a forward-slash cwd against an un-normalized home, so a chat cwd on Windows missed the chat branch and was routed to the project-workspace path (which requires the directory to exist). Normalize the home separators, as \is_desktop_chat_cwd\ already does. - \�est_effort_canonical\ returned the Windows extended-length spelling (\\\\\?\\D:\\...\) straight to the webview and the OS opener. Strip it, and normalize both sides of the credential denylist so the guard keeps blocking them. - \sh -c\ does not exist on Windows; use \cmd /C\ for the non-zero-exit fixture. - Two tests hard-coded \/Users/fake-home\ as HOME, which \home_dir_from\ rejects as non-absolute on Windows, silently falling back to the real profile. - Presence awaits matched on the subject only, but the heartbeat, disconnect notice and unpair notice all publish to \p.<pair>.presence\, so the assertion could consume the wrong message. Match on the payload; add \�wait_publish_matching\. - Three tests asserted a task had finished after a fixed sleep. Replace with a bounded poll (\wait_until\), since an aborted read surfaces much later on Windows.
Both fake-HOME guards delete their directory on drop, but on Windows the delete failed silently: the connection pool still held an open handle to that home's SQLite database, and Windows refuses to unlink an open file. Every run leaked its test homes - 18,963 directories / 32.7 GB had accumulated here, leaving C: with 10 MB free, which is what made unrelated tests fail intermittently with SQLite \DatabaseBusy\ (a full disk cannot write WAL) and \StorageFull\. Add a test-only \store::close_pool()\ and call it from both guards before removing the directory, so the handles are released first. The accompanying regression test leaves a pooled connection open across the drop and fails without the fix. Residual: some homes are still leaked (~120 per run) where a background task holds a checked-out connection past the guard, so the directory is briefly undeletable. Reclaiming is safe (\ mdir /s /q %TEMP%\\futureos*\).
…ixes # Conflicts: # desktop/src-tauri/src/remote/mod.rs
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.
Problem
Running
cargo testunderdesktop/src-taurion Windows failed 26 tests, 100% reproducibly. Every one was a latent platform assumption rather than an environment quirk — and two were real product bugs that only the Windows path exposes.A separate, intermittent failure (≈1 run in 6, a different test each time:
DatabaseBusy: database is locked/StorageFull) turned out to be the disk being full: the fake-HOME test guards leak their temp directories (~19k dirs / 32.7 GB accumulated, leaving C: with 10 MB free). A full disk cannot write SQLite's WAL, which surfaces as those two errors.Fixes
Product bugs
reconcile_thread_workspacecompared a forward-slash cwd against an un-normalized home, so a chat cwd on Windows missed the chat branch and was routed to the project-workspace path, which requires the directory to already exist. Normalize the home separators, asis_desktop_chat_cwdalready does.best_effort_canonicalreturned the Windows extended-length spelling (\\?\D:\...) straight to the webview and the OS opener. Strip it, and normalize both sides of the credential denylist — otherwise the mismatch would silently stop blockingauth.json.Test fixes
set_modifiedon a read-only handle raisesACCESS_DENIEDon Windows (it needsFILE_WRITE_ATTRIBUTES). Open for writing instead — this alone accounted for 20 failures.sh -cdoes not exist on Windows; build the non-zero-exit fixture withcmd /C./Users/fake-homeas HOME, whichhome_dir_fromrejects as non-absolute on Windows and silently falls back to the real profile.p.<pair>.presence, so the assertion could consume the wrong message. Match on the payload (await_publish_matching). Note:origin/mainfixed one of these independently with an inline loop; this branch keeps the shared helper it already uses at three other sites.wait_until), since an aborted NATS read surfaces much later on Windows.Test-infrastructure leak
store::close_pool()and call it before removing the directory. The regression test leaves a pooled connection open across the drop and fails without the fix.Result
cargo testunderdesktop/src-tauri: 1164 passed, 0 failed, green on 7 consecutive full-suite runs (the intermittentDatabaseBusy/StorageFullfailures are gone).cargo fmt --checkandcargo clippy --all-targets -- -D warningsclean.Known remaining issue (not fixed here)
The guards still leak ~120 temp homes per run when a background task holds a checked-out connection past the guard's drop, so the directory is briefly undeletable.
close_poolonly releases pooled connections, not ones still in use. Reclaiming is safe when no run is active:rmdir /s /q %TEMP%\futureos*. Worth a follow-up that stops observers/heartbeats before the guard drops.