summaryrefslogtreecommitdiffstats
path: root/vendor/gix-glob/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 18:31:44 +0000
commitc23a457e72abe608715ac76f076f47dc42af07a5 (patch)
tree2772049aaf84b5c9d0ed12ec8d86812f7a7904b6 /vendor/gix-glob/tests
parentReleasing progress-linux version 1.73.0+dfsg1-1~progress7.99u1. (diff)
downloadrustc-c23a457e72abe608715ac76f076f47dc42af07a5.tar.xz
rustc-c23a457e72abe608715ac76f076f47dc42af07a5.zip
Merging upstream version 1.74.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/gix-glob/tests')
-rwxr-xr-x[-rw-r--r--]vendor/gix-glob/tests/fixtures/make_baseline.sh0
-rw-r--r--vendor/gix-glob/tests/parse/mod.rs10
-rw-r--r--vendor/gix-glob/tests/pattern/matching.rs32
-rw-r--r--vendor/gix-glob/tests/search/pattern.rs22
-rw-r--r--vendor/gix-glob/tests/wildmatch/mod.rs8
5 files changed, 60 insertions, 12 deletions
diff --git a/vendor/gix-glob/tests/fixtures/make_baseline.sh b/vendor/gix-glob/tests/fixtures/make_baseline.sh
index 5787ff64c..5787ff64c 100644..100755
--- a/vendor/gix-glob/tests/fixtures/make_baseline.sh
+++ b/vendor/gix-glob/tests/fixtures/make_baseline.sh
diff --git a/vendor/gix-glob/tests/parse/mod.rs b/vendor/gix-glob/tests/parse/mod.rs
index fc668d1e6..8377a44f2 100644
--- a/vendor/gix-glob/tests/parse/mod.rs
+++ b/vendor/gix-glob/tests/parse/mod.rs
@@ -66,11 +66,21 @@ fn leading_exclamation_mark_negates_pattern() {
gix_glob::parse(b"!hello"),
pat("hello", Mode::NEGATIVE | Mode::NO_SUB_DIR, None)
);
+ assert_eq!(
+ gix_glob::Pattern::from_bytes_without_negation(b"!hello"),
+ pat("!hello", Mode::NO_SUB_DIR, None),
+ "negation can be disabled entirely"
+ );
}
#[test]
fn leading_exclamation_marks_can_be_escaped_with_backslash() {
assert_eq!(gix_glob::parse(br"\!hello"), pat("!hello", Mode::NO_SUB_DIR, None));
+ assert_eq!(
+ gix_glob::Pattern::from_bytes_without_negation(br"\!hello"),
+ pat("\\!hello", Mode::NO_SUB_DIR, Some(0)),
+ "negation can be disabled entirely, leaving escapes in place"
+ );
}
#[test]
diff --git a/vendor/gix-glob/tests/pattern/matching.rs b/vendor/gix-glob/tests/pattern/matching.rs
index 8a5208d9a..df29e02dc 100644
--- a/vendor/gix-glob/tests/pattern/matching.rs
+++ b/vendor/gix-glob/tests/pattern/matching.rs
@@ -68,7 +68,13 @@ fn compare_baseline_with_ours() {
);
match std::panic::catch_unwind(|| {
let pattern = pat(pattern);
- pattern.matches_repo_relative_path(value, basename_start_pos(value), None, *case)
+ pattern.matches_repo_relative_path(
+ value,
+ basename_start_pos(value),
+ None,
+ *case,
+ gix_glob::wildmatch::Mode::NO_MATCH_SLASH_LITERAL,
+ )
}) {
Ok(actual_match) => {
if actual_match == is_match {
@@ -105,11 +111,23 @@ fn non_dirs_for_must_be_dir_patterns_are_ignored() {
);
let path = "hello";
assert!(
- !pattern.matches_repo_relative_path(path, None, false.into() /* is-dir */, Case::Sensitive),
+ !pattern.matches_repo_relative_path(
+ path.into(),
+ None,
+ false.into(), /* is-dir */
+ Case::Sensitive,
+ gix_glob::wildmatch::Mode::NO_MATCH_SLASH_LITERAL
+ ),
"non-dirs never match a dir pattern"
);
assert!(
- pattern.matches_repo_relative_path(path, None, true.into() /* is-dir */, Case::Sensitive),
+ pattern.matches_repo_relative_path(
+ path.into(),
+ None,
+ true.into(), /* is-dir */
+ Case::Sensitive,
+ gix_glob::wildmatch::Mode::NO_MATCH_SLASH_LITERAL
+ ),
"dirs can match a dir pattern with the normal rules"
);
}
@@ -317,7 +335,13 @@ fn match_file<'a>(pattern: &gix_glob::Pattern, path: impl Into<&'a BStr>, case:
fn match_path<'a>(pattern: &gix_glob::Pattern, path: impl Into<&'a BStr>, is_dir: Option<bool>, case: Case) -> bool {
let path = path.into();
- pattern.matches_repo_relative_path(path, basename_start_pos(path), is_dir, case)
+ pattern.matches_repo_relative_path(
+ path,
+ basename_start_pos(path),
+ is_dir,
+ case,
+ gix_glob::wildmatch::Mode::NO_MATCH_SLASH_LITERAL,
+ )
}
fn basename_start_pos(value: &BStr) -> Option<usize> {
diff --git a/vendor/gix-glob/tests/search/pattern.rs b/vendor/gix-glob/tests/search/pattern.rs
index 0313b5564..6b62ee3d2 100644
--- a/vendor/gix-glob/tests/search/pattern.rs
+++ b/vendor/gix-glob/tests/search/pattern.rs
@@ -18,16 +18,12 @@ mod list {
fn bytes_to_patterns(_bytes: &[u8], _source: &Path) -> Vec<Mapping<Self::Value>> {
vec![]
}
-
- fn may_use_glob_pattern(_pattern: &gix_glob::Pattern) -> bool {
- unreachable!("won't be called")
- }
}
#[test]
fn from_bytes_base() {
{
- let list = List::<Dummy>::from_bytes(&[], "a/b/source", None);
+ let list = List::<Dummy>::from_bytes(&[], "a/b/source".into(), None);
assert_eq!(list.base, None, "no root always means no-base, i.e. globals lists");
assert_eq!(
list.source.as_deref(),
@@ -52,7 +48,7 @@ mod list {
}
{
- let list = List::<Dummy>::from_bytes(&[], "a/b/source", Some(Path::new("c/")));
+ let list = List::<Dummy>::from_bytes(&[], "a/b/source".into(), Some(Path::new("c/")));
assert_eq!(
list.base, None,
"if root doesn't contain source, it silently skips it as base"
@@ -67,7 +63,7 @@ mod list {
#[test]
fn strip_base_handle_recompute_basename_pos() {
- let list = List::<Dummy>::from_bytes(&[], "a/b/source", Some(Path::new("")));
+ let list = List::<Dummy>::from_bytes(&[], "a/b/source".into(), Some(Path::new("")));
assert_eq!(
list.base.as_ref().expect("set"),
"a/b/",
@@ -87,4 +83,16 @@ mod list {
"otherwise the basename is recomputed, case folding is effective"
);
}
+
+ #[test]
+ fn from_file() {
+ let mut buf = Vec::new();
+ for path in [
+ Path::new(".").join("non-existing-dir").join("pattern-file"),
+ Path::new("file").to_owned(),
+ ] {
+ let list = List::<Dummy>::from_file(path, None, false, &mut buf).expect("no io error");
+ assert!(list.is_none(), "the file does not exist");
+ }
+ }
}
diff --git a/vendor/gix-glob/tests/wildmatch/mod.rs b/vendor/gix-glob/tests/wildmatch/mod.rs
index 11fbd664b..b4b198ec7 100644
--- a/vendor/gix-glob/tests/wildmatch/mod.rs
+++ b/vendor/gix-glob/tests/wildmatch/mod.rs
@@ -367,7 +367,13 @@ impl Display for MatchResult {
}
fn match_file_path(pattern: &gix_glob::Pattern, path: &str, case: Case) -> bool {
- pattern.matches_repo_relative_path(path, basename_of(path), false.into() /* is_dir */, case)
+ pattern.matches_repo_relative_path(
+ path.into(),
+ basename_of(path),
+ false.into(), /* is_dir */
+ case,
+ gix_glob::wildmatch::Mode::NO_MATCH_SLASH_LITERAL,
+ )
}
fn basename_of(path: &str) -> Option<usize> {
path.rfind('/').map(|pos| pos + 1)