Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use is_symlink() method
  • Loading branch information
maxwase committed Jan 13, 2022
commit 2623af0c432230d249b66f9581be8a46dfb27b4b
8 changes: 0 additions & 8 deletions crates/cargo-test-support/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,6 @@ impl CargoPathExt for Path {
}
}

// Replace with std implementation when stabilized, see
// https://github.com/rust-lang/rust/issues/85748
pub fn is_symlink(path: &Path) -> bool {
fs::symlink_metadata(path)
.map(|m| m.file_type().is_symlink())
.unwrap_or(false)
}

fn do_op<F>(path: &Path, desc: &str, mut f: F)
where
F: FnMut(&Path) -> io::Result<()>,
Expand Down
1 change: 0 additions & 1 deletion crates/cargo-util/src/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ pub fn remove_dir_all<P: AsRef<Path>>(p: P) -> Result<()> {
fn _remove_dir_all(p: &Path) -> Result<()> {
if p.symlink_metadata()
.with_context(|| format!("could not get metadata for `{}` to remove", p.display()))?
.file_type()
.is_symlink()
{
return remove_file(p);
Expand Down
6 changes: 2 additions & 4 deletions tests/testsuite/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4805,7 +4805,6 @@ fn building_a_dependent_crate_witout_bin_should_fail() {
#[cargo_test]
#[cfg(any(target_os = "macos", target_os = "ios"))]
fn uplift_dsym_of_bin_on_mac() {
use cargo_test_support::paths::is_symlink;
let p = project()
.file("src/main.rs", "fn main() { panic!(); }")
.file("src/bin/b.rs", "fn main() { panic!(); }")
Expand All @@ -4818,7 +4817,7 @@ fn uplift_dsym_of_bin_on_mac() {
.run();
assert!(p.target_debug_dir().join("foo.dSYM").is_dir());
assert!(p.target_debug_dir().join("b.dSYM").is_dir());
assert!(is_symlink(&p.target_debug_dir().join("b.dSYM")));
assert!(p.target_debug_dir().join("b.dSYM").is_symlink());
assert!(p.target_debug_dir().join("examples/c.dSYM").is_dir());
assert!(!p.target_debug_dir().join("c.dSYM").exists());
assert!(!p.target_debug_dir().join("d.dSYM").exists());
Expand All @@ -4827,7 +4826,6 @@ fn uplift_dsym_of_bin_on_mac() {
#[cargo_test]
#[cfg(any(target_os = "macos", target_os = "ios"))]
fn uplift_dsym_of_bin_on_mac_when_broken_link_exists() {
use cargo_test_support::paths::is_symlink;
let p = project()
.file("src/main.rs", "fn main() { panic!(); }")
.build();
Expand All @@ -4846,7 +4844,7 @@ fn uplift_dsym_of_bin_on_mac_when_broken_link_exists() {
.join("foo-baaaaaadbaaaaaad.dSYM"),
&dsym,
);
assert!(is_symlink(&dsym));
assert!(dsym.is_symlink());
assert!(!dsym.exists());

p.cargo("build").enable_mac_dsym().run();
Expand Down
3 changes: 1 addition & 2 deletions tests/testsuite/clean.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
//! Tests for the `cargo clean` command.

use cargo_test_support::paths::is_symlink;
use cargo_test_support::registry::Package;
use cargo_test_support::{
basic_bin_manifest, basic_manifest, git, main_file, project, project_in, rustc_host,
Expand Down Expand Up @@ -476,7 +475,7 @@ fn assert_all_clean(build_dir: &Path) {
{
continue;
}
if is_symlink(path) || path.is_file() {
if path.is_symlink() || path.is_file() {
panic!("{:?} was not cleaned", path);
}
}
Expand Down