fix(core/build): build test file:// URLs with Url::from_file_path (#3137) - #3138
Conversation
|
😎 Merged successfully - details. |
|
🤖 Automated review by Claude — this review was generated fully automatically, with no human in the loop. I reviewed this change and don't see any issues. The six converted sites all pass absolute Generated by Claude Code |
|
The Evidence it's environmental rather than mine:
#3006 ( Everything else on this PR is green: Format, Clippy, Check, Typos, Unwrap budget, License check. Generated by Claude Code |
) `format!("file://{}", path.display())` is not portable. On Windows it yields `file://C:\Users\...`, which puts the drive letter in the URL authority and leaves the backslashes as non-separators, so libgit2 refuses to resolve it: failed to resolve path 'file://C:\Users\RUNNER~1\...\origin': The filename, directory name, or volume label syntax is incorrect. The tests added in #2809 hand that string straight to `git2::Repository::clone`, which broke `copy_and_fetch_promotes_into_target` and `rename_and_fetch_promotes_into_target` on the nightly Windows runner. The sites that funnelled the same string through `Url::parse` survived only because the url crate silently normalizes the malformed spelling. Route every test-side `file://` construction through one `file_url` helper built on `Url::from_file_path`, which emits the well-formed `file:///C:/Users/...` on all platforms. Production is unaffected: `clone_into` already takes an already-parsed `Url`. Two `Url::parse(&repo_url_str).unwrap()` round-trips fall out as dead weight now that the helper hands back a `Url` directly. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01C74rZYpFMVdg4B9HHt5BYL
31d8150 to
4510a72
Compare
Fixes #3137 — the
test-cross-platformnightly failure on the Windows runner.The failure
Two tests in
libraries/core/src/build/git.rsfailed on the Windows runner (333 passed, 2 failed):Line 1259 was the test helper
clone_from_origin:format!("file://{}", path.display())is only well-formed for a/-rooted Unix path. On Windows it producesfile://C:\Users\..., which puts the drive letter in the URL authority and leaves the backslashes as non-separators, so the string doesn't address the repo at all and libgit2 refuses to resolve it.Introduced by #2809 (merged 2026-08-11), which added the Copy/Rename promotion tests and this helper; the nightly failed the next morning. The other
format!("file://…")sites in the module survived only because they funnel the string throughUrl::parse, and the url crate silently normalizes the malformed spelling tofile:///C:/….Production is not affected.
clone_into(libraries/core/src/build/git.rs:632) takes an already-parsedurl::Url, andGitManager::choose_clone_dirparses the descriptor'sgit:field withUrl::parse, so a real build never sees the rawformat!spelling. This is a test-side bug only — the same run'snew_clone_promotes_temp_into_target_and_cleans_up, which clones through a parsedUrl, passed on that Windows runner.The change
Route every test-side
file://construction through one helper:Url::from_file_pathemits the well-formedfile:///C:/Users/…on every platform, so the tests now exercise the same URL shape production does. Six call sites converted;clone_from_originpassesfile_url(origin).as_str()straight to git2.Two
Url::parse(&repo_url_str).unwrap()round-trips fall out as dead weight, since the helper hands back aUrlthe tests can pass toclone_dir_pathdirectly.No production code changed; no behavior change on Linux/macOS, where the old and new spellings are byte-identical.
Validation
Class A (test-only, no behavior change), per
docs/agentic-qa-policy.md:cargo test -p dora-core --all-features— 339 passed, 0 failed (the 23build::git::tests::*included)cargo fmt --all -- --check— cleancargo clippy -p dora-core --all-features --all-targets -- -D warnings— clean/review— no findings;/simplify— applied its findings (dropped a self-referential round-trip test that only exercised theurlcrate, trimmed the duplicated comment, removed the two redundant re-parses)Not run locally: the full
cargo test --allsweep — this container ran out of disk partway through linking the workspace's example binaries (No space left on device), not on any test failure. Since the change lives entirely inside dora-core's#[cfg(test)]module, no other crate compiles it. The Windows half of the fix is verified by the nightlytest-cross-platformjob, which is what has to go green.Out of scope
tests/hub-smoke.rshas six instances of the sameformat!("file://{}", src.display())idiom (lines 107, 636, 687, 710, 770, 810). Its nightly job isubuntu-latestonly, so they are not currently broken; worth a follow-up if hub-smoke ever runs on Windows.Generated by Claude Code