Repository navigation
test(tauri): retry temp_dir_for canonicalization instead of falling back - #262
Closed
LIUBINfighter wants to merge 1 commit into
Closed
LIUBINfighter wants to merge 1 commit into
LIUBINfighter wants to merge 1 commit into
Conversation
CI on #261 failed once with tests::delete_file_repo_trash_rejects_paths_outside_the_repo_root left: Some("No such file or directory (os error 2)") right: Some("path-outside-workspace") and passed on rerun. The assertion is about path scope, but the error is an ENOENT that comes from `fs::canonicalize` inside `authorize_existing_workspace_path`, called on a file the test had just written. `temp_dir_for` is supposed to resolve macOS firmlinks (`/var` -> `/private/var`) once up front precisely so later canonicalize calls on files inside the directory do not have to cross that boundary. It ended with fs::canonicalize(&dir).unwrap_or(dir) so whenever that canonicalize did fail, the fixture silently kept the unresolved `/var/...` path and every later canonicalize of an entry inside the directory went back to racing the firmlink -- the failure then surfaced as a bogus ENOENT in an unrelated scope assertion rather than anywhere near its cause. Retry the canonicalize for up to 10s and fail loudly with the real path and error if it still does not resolve, so a genuine fixture problem cannot masquerade as a path-authorization regression again. Test-only code; `cargo test` (27 passed), `cargo fmt --check` clean.
Owner
Author
|
Superseded by #263. The first pass blamed |
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 happened
CI on #261 failed once and passed on rerun:
The assertion is about workspace path scope, but the reported error is an ENOENT raised by
fs::canonicalizeinsideauthorize_existing_workspace_path, called on a file the test had just written a few lines earlier. The scope logic never got a chance to run.Why the fixture was the cause
temp_dir_foralready documents the problem it is meant to solve:It then ended with:
So whenever that one canonicalize call failed, the fixture silently kept the unresolved
/var/...path. Every laterfs::canonicalizeof a freshly created entry inside the directory then had to cross the firmlink again, which is exactly the race the comment says it removed. The symptom appears as a bogus ENOENT in an unrelated scope assertion, which is a very expensive way to learn that a temp directory was not resolved.Change
Test-only code, no production behaviour change.
Verification
cargo test— 27 passedcargo fmt --check— cleancargo clippy --all-targets— no new warnings (theitems after a test modulewarning is pre-existing and unrelated)cargo test --librun 12 times locally plus 15 runs of the specific test: no failures, confirming the flake is environment-specific rather than reproducible on this machine