Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected behavior with ** patterns #61

Open
azdavis opened this issue Sep 20, 2024 · 0 comments
Open

unexpected behavior with ** patterns #61

azdavis opened this issue Sep 20, 2024 · 0 comments

Comments

@azdavis
Copy link

azdavis commented Sep 20, 2024

repo with test case here: https://github.com/azdavis/wax-trouble

tldr is: given this directory structure:

testing
\ _ a
    \ _ foo.txt
\ _ b
    \ _ foo.txt

and this rust code:

#[test]
fn hm() {
    let all_foo = "**/foo.txt";
    let pwd = std::env::current_dir().unwrap();
    let testing_dir = pwd.join("testing");
    let testing_dir = testing_dir.as_os_str().to_str().unwrap();
    let glob_rooted_at_dir_walk_anything: Vec<_> = go(&format!("{testing_dir}/{all_foo}"), ".");
    let glob_un_rooted_walk_in_dir: Vec<_> = go(all_foo, &testing_dir);
    assert_eq!(glob_rooted_at_dir_walk_anything, glob_un_rooted_walk_in_dir);
}

pub fn go(glob: &str, walk: &str) -> Vec<std::path::PathBuf> {
    wax::Glob::new(glob)
        .unwrap()
        .walk(walk)
        .map(|x| x.unwrap().into_path())
        .collect()
}

i would expect the test to pass but it does not. it fails with:

thread 'hm' panicked at src/lib.rs:9:5:
assertion `left == right` failed
  left: []
 right: [".../wax-trouble/testing/a/foo.txt", ".../wax-trouble/testing/b/foo.txt"]

where ... is the absolute path containing the repo.

i would not expect the lhs (glob_rooted_at_dir_walk_anything) to be empty. i would expect it to be the same as the rhs (glob_un_rooted_walk_in_dir).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant