Skip to content

Fix cache invalidation on Windows, and the tests that fail on Windows and macOS - #134

Open
armada45-pixel wants to merge 2 commits into
tobi:mainfrom
armada45-pixel:fix/windows-macos-tests
Open

armada45-pixel wants to merge 2 commits into
tobi:mainfrom
armada45-pixel:fix/windows-macos-tests

Conversation

@armada45-pixel

@armada45-pixel armada45-pixel commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

CI is red on main on Windows and macOS, so every open PR shows failing checks. One of the failures is a real cache bug on Windows; the rest are tests that assumed another platform.

The bug. The scan cache found a path's parent and leaf by splitting on /. On Windows its keys are canonical \?\C:\... paths, so invalidate never found an indexed ancestor, and the lookup for cached subtrees never matched. A deleted file stayed in --json output after disktree-cli invalidate, and a wider scan never reused a cached subtree. The helpers in db.rs now go through Path.

Test-only changes.

  • stdio.rs: macOS keeps its cache in $HOME/Library/Caches and ignores XDG_CACHE_HOME, so the persistence test sets HOME too and looks there.
  • db.rs: the roundtrip test is rooted in a canonical temporary directory, as a real scan is, instead of a driveless /fake.
  • space.rs, mounts.rs: the two btrfs mount-table tests are cfg(unix). They use POSIX paths, which are not absolute on Windows.
  • removal.rs: the two lossy-name tests are skipped on macOS. APFS refuses a name that is not UTF-8, so they cannot set up their case. They still run on Linux.
  • space.rs: the pseudo-filesystem test compares which volumes remain, not their order, which depends on how full the runner's disks are.
  • stream.rs: the hardlink test expects a double count off Unix, because the streaming walker has no file identity there. This records the current behaviour rather than fixing it.

Verified. cargo xtask lint and the workspace tests are green on Windows. A trial run of this workflow on my fork ended with all 6 jobs green: armada45-pixel#1.

Two flaky tests, fixed in #135. In that trial run the Linux "Lint and test" job passed only on a rerun of the same commit:

  • escape_cancels_the_first_scan_and_r_starts_it_again failed on the first attempt of that run.
  • enter_in_the_focused_volume_picker_scans_the_selected_root failed on the run before it, one commit earlier.

The fixture's scan can finish before the test acts on it; #135 reproduces both failures with a delay and fixes the cause. This PR does not touch disktree-app, and its tests use in-memory storage, so they do not reach the changed code.

Overlap. #132 also gates one of the btrfs tests (local_btrfs_scan_keeps_distinct_subvolumes_but_not_aliases_or_network).

🤖 Generated with Claude Code

armada45-pixel and others added 2 commits November 30, 2026 05:11
The scan cache keyed its parent and leaf lookups by splitting on '/'.
On Windows the keys are canonical `\?\C:\...` paths with no '/', so
`invalidate` never found an indexed ancestor and the fresh-subtree
catalog never matched: a deleted file stayed in `--json` output after
`disktree-cli invalidate`, and a wider scan never reused a cached
subtree. The helpers now go through `Path`, which is unchanged on Unix.

Test-only adjustments, each where the test was wrong for the platform:

- stdio: macOS keeps its cache in `$HOME/Library/Caches` and ignores
  XDG_CACHE_HOME, so the persistence test also points HOME at its
  temporary directory and looks for the DB at the macOS path.
- db roundtrip: root the synthetic tree in a canonical temp directory,
  as real scan roots are, instead of a driveless `/fake` on Windows.
- btrfs mount-table tests: gate to unix; the code only runs on Linux
  and `/@home` is not an absolute path on Windows.
- streaming hardlink test: the streaming walker has no file identity
  off Unix, so a hardlink is counted twice there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
APFS refuses a name that is not UTF-8, so the lossy-name removal tests
cannot set up their case there. And volume candidates come fullest first
on the machine running the test, so the pseudo-filesystem test compares
which disks remain, not their order.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant