fix: keep the selftest workdir inside the fs scope on Windows - #36
Merged
Merged
Conversation
makeWorkdir() hardcoded /tmp, which on Windows is drive-relative: it resolved against the process's current drive (D:\tmp with the repo on D:) and stayed in the capability scope only because Tauri canonicalized the /tmp/** pattern against that same drive. Use the OS temp dir there — it sits under the user profile, which the $HOME/** scope entry already covers — and keep /tmp on macOS/Linux, where the macOS temp dir is deliberately out of scope. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
Important Review available on request
Reviews should be triggered manually for repositories with fewer than 10 stars. Select Trigger review above or comment ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
What this is
Portability hardening for the selftest harness, not a bug fix —
bun run selftestpassed 15/15 on Windows before this change. Found while tracing an unrelated fs-scope
failure.
The latent problem
makeWorkdir()insrc/selftest/mount.tsxpicked the selftest scratch directory as ahardcoded POSIX path:
On Windows that path is drive-relative, not absolute: it resolves against the process's
current drive. With the repo checked out on
D:, the selftest wrote toD:\tmp\lopload-selftest-*— littering the drive root, and inside the capability scopeonly by accident, because tauri canonicalises the
/tmp/**pattern against that sameworking drive. Move the checkout, or run with a different working drive, and the
reasoning behind the choice stops holding.
The original comment justified
/tmpin Unix terms: the shipped scope allows/tmp/**while the macOS temp dir (
/var/folders/…) deliberately is not in scope, and the authordid not want to add a capability grant to the shipped app purely for tests. That
reasoning is correct on macOS/Linux and is preserved here.
What changed
src/selftest/mount.tsx,makeWorkdir()only:$HOME/**scope entry already covers; macOS/Linux keep
/tmpfor the reason above.hostparameter(
host.files.tempDir()/host.files.join()), so no new imports and nothing node-onlyenters the selftest module graph.
Unix-only assumption.
Mixed separators still match: tauri 2.11.5's
Scope::is_allowednormalises separators viapath.components().collect()(and canonicalises existing paths) before glob matching, sothe
${workdir}/${name}paths scenarios build are matched correctly against$HOME/**.Verification
All on Windows, repo on
D:, against the real MinIO on port 9400:bun run typecheckbun test tests/unitbun test tests/app.test.tsbun run selftest(Runner B, real Tauri binary)SELFTEST_RESULT PASS total=15 passed=15 failed=0Workdir location confirmed after the run: 15 fresh
lopload-selftest-*directories (oneper scenario) under
C:\Users\<user>\AppData\Local\Temp\, and no new directories inD:\tmp.Not verified on macOS or Linux; behaviour there is unchanged by construction (the
non-Windows branch is the previous code path).
🤖 Generated with Claude Code