Add tests for ignoring symlinks#10047
Conversation
|
r? @ehuss (rust-highfive has picked a reviewer for you, use r? to override) |
|
The Windows failure here is surprising. It suggests that on Windows, Cargo considers the symlinks files, not directories, and thus they don't match cargo/src/cargo/sources/path.rs Lines 395 to 396 in b747054 Even though the docs for
🤔 Given that I don't have a Windows computer handy to debug with, I think this has me stomped for now. I'll just add that the fix I had originally intended for #10032 is let is_dir = path.is_dir();
// Symlinks that point to directories are a little odd because they are both directories
// _and_ files for the purposes of matching. At least as far as Cargo is concerned, since
// we never include symlinks directly in the pacakge. The actual rules are:
//
// 1. A pattern of `/symlink` should match the symlink itself.
// 2. A pattern of `/symlink/` should match the symlink's target's contents.
//
// But for us, this means that if a directory symlink is excluded as either a directory
// _or_ a file, it should be skipped.
if !is_root && is_dir {
let is_symlink = path.symlink_metadata()?.file_type().is_symlink();
// See if the symlink is filtered out when viewed as a file -- if so, skip it.
// The directory case is handled by the regular logic below.
if is_symlink && !(*filter)(path, false)? {
return Ok(());
}
}
if !is_root && !(*filter)(path, is_dir)? {which may come in handy for whoever decides to try tackling this. |
|
I believe the issue here is with libgit2. When creating the repository, the If you want to just disable these tests on Windows, I think it would be fine. |
a131771 to
79cc65f
Compare
|
Pushed a change that ignores the test on Windows 👍 |
|
Thanks! @bors r+ |
|
📌 Commit 79cc65f has been approved by |
|
☀️ Test successful - checks-actions |
Update cargo 13 commits in 109bfbd055325ef87a6e7f63d67da7e838f8300b..1ef1e0a12723ce9548d7da2b63119de9002bead8 2022-03-17 21:43:09 +0000 to 2022-03-31 00:17:18 +0000 - Support `-Zmultitarget` in cargo config (rust-lang/cargo#10473) - doc: Fix document url for libcurl format (rust-lang/cargo#10515) - Fix wrong info in "Environment variables" docs (rust-lang/cargo#10513) - Use the correct flag in --locked --offline error message (rust-lang/cargo#10512) - Don't treat host/target duplicates as duplicates (rust-lang/cargo#10466) - Unstable --keep-going flag (rust-lang/cargo#10383) - Part 1 of RFC2906 - Packages can inherit fields from their root workspace (rust-lang/cargo#10497) - Remove unused profile support for -Zpanic-abort-tests (rust-lang/cargo#10495) - HTTP registry implementation (rust-lang/cargo#10470) - Add a notice about review capacity. (rust-lang/cargo#10501) - Add tests for ignoring symlinks (rust-lang/cargo#10047) - Update doc string for deps_of/compute_deps. (rust-lang/cargo#10494) - Consistently use crate::display_error on errors during drain (rust-lang/cargo#10394)
This adds tests for the expected behavior in #10032. Interestingly, these tests pass (🎉). Will update that issue with more details shortly, but figured these tests were worthwhile to add to the testsuite anyway now that I've written them.