From 706323ad8f2600db7d46482a7d95972b1416c0eb Mon Sep 17 00:00:00 2001 From: Behnam Esfahbod Date: Sun, 4 Feb 2018 18:07:55 -0800 Subject: [PATCH] globset: add more tests for single-asterisk pattern This adds a few tests that check for bugs reported here: https://github.com/rust-lang/cargo/issues/4268 The bugs reported in the aforementioned issue are probably caused by not enabling the `literal_separator` option in `GlobBuilder`. Enabling that in the tests under question fixes the issue. Closes #773 --- globset/src/glob.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/globset/src/glob.rs b/globset/src/glob.rs index ff7b74aa..05467d50 100644 --- a/globset/src/glob.rs +++ b/globset/src/glob.rs @@ -1155,6 +1155,7 @@ mod tests { matches!(matchrec22, ".*/**", ".abc/abc"); matches!(matchrec23, "foo/**", "foo"); matches!(matchrec24, "**/foo/bar", "foo/bar"); + matches!(matchrec25, "some/*/needle.txt", "some/one/needle.txt"); matches!(matchrange1, "a[0-9]b", "a0b"); matches!(matchrange2, "a[0-9]b", "a9b"); @@ -1243,6 +1244,13 @@ mod tests { nmatches!(matchnot27, "a[^0-9]b", "a0b"); nmatches!(matchnot28, "a[^0-9]b", "a9b"); nmatches!(matchnot29, "[^-]", "-"); + nmatches!(matchnot30, "some/*/needle.txt", "some/needle.txt"); + nmatches!( + matchrec31, + "some/*/needle.txt", "some/one/two/needle.txt", SLASHLIT); + nmatches!( + matchrec32, + "some/*/needle.txt", "some/one/two/three/needle.txt", SLASHLIT); macro_rules! extract { ($which:ident, $name:ident, $pat:expr, $expect:expr) => {