From 78a11ad69bfc84d6cf860bd2107991de3619445d Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Sun, 3 Jul 2022 13:25:18 -0400 Subject: [PATCH] tests/common/util: add AtPath::symlink_exists() Add helper method for deciding whether a symbolic link exists in the test directory. --- tests/common/util.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/common/util.rs b/tests/common/util.rs index d601b90d8..97d435875 100644 --- a/tests/common/util.rs +++ b/tests/common/util.rs @@ -755,6 +755,14 @@ impl AtPath { } } + /// Decide whether the named symbolic link exists in the test directory. + pub fn symlink_exists(&self, path: &str) -> bool { + match fs::symlink_metadata(&self.plus(path)) { + Ok(m) => m.file_type().is_symlink(), + Err(_) => false, + } + } + pub fn dir_exists(&self, path: &str) -> bool { match fs::metadata(&self.plus(path)) { Ok(m) => m.is_dir(),