mitsuhiko / insta

A snapshot testing library for rust
https://insta.rs
Apache License 2.0
2.26k stars 102 forks source link

glob macro gives bad error message for parent dirs #623

Open max-sixty opened 2 months ago

max-sixty commented 2 months ago

What happened?

This panics on not finding files:

#[test]
fn test_glob_path() {

    insta::glob!("../**/*.rs", |path| {
        let input = std::fs::read_to_string(path).unwrap();
        insta::assert_snapshot!(input);
    })

}
failures:

---- test_glob_path stdout ----
thread 'test_glob_path' panicked at /Users/maximilian/workspace/insta/insta/src/glob.rs:112:9:
the glob! macro did not match any files.
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Reproduction steps

As above

Insta Version

1.40

rustc Version

1.80

What did you expect?

At the least we should give an error message saying parent paths aren't supported.

Should we allow this or is it a security risk? @mitsuhiko ?

It's not doing anything that rust can't do ofc. But perhaps we want insta tests to be safe?