Skip to content

Commit

Permalink
Add symlink test
Browse files Browse the repository at this point in the history
  • Loading branch information
Kobzol committed Jan 2, 2024
1 parent 4054779 commit 63cbe52
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions tests/glob-std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,19 @@ fn main() {
}
}

fn mk_symlink_dir(original: &str, link: &str) {
#[cfg(unix)]
{
use std::os::unix::fs::symlink;
symlink(original, link).unwrap();
}
#[cfg(windows)]
{
use std::os::windows::fs::symlink_dir;
symlink_dir(original, link).unwrap();
}
}

fn glob_vec(pattern: &str) -> Vec<PathBuf> {
glob(pattern).unwrap().map(|r| r.unwrap()).collect()
}
Expand Down Expand Up @@ -99,6 +112,22 @@ fn main() {
mk_file("r/three", true);
mk_file("r/three/c.md", false);

mk_file("dirsym", true);
mk_symlink_dir("../r", "dirsym/link");

assert_eq!(
glob_vec("dirsym/**/*.md"),
vec!(
PathBuf::from("dirsym/link/another/a.md"),
PathBuf::from("dirsym/link/current_dir.md"),
PathBuf::from("dirsym/link/one/a.md"),
PathBuf::from("dirsym/link/one/another/a.md"),
PathBuf::from("dirsym/link/one/another/deep/spelunking.md"),
PathBuf::from("dirsym/link/three/c.md"),
PathBuf::from("dirsym/link/two/b.md")
)
);

// all recursive entities
assert_eq!(
glob_vec("r/**"),
Expand Down

0 comments on commit 63cbe52

Please sign in to comment.