Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fe3d0a7

Browse files
committed
git-baseline now acts like a massive regression test (#301)
Thus it will only keep a failure count, which we try to boost to 100% over time.
1 parent b947ff9 commit fe3d0a7

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

git-glob/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub mod pattern {
7878
Case::Fold => MatchOptions::IGNORE_CASE,
7979
Case::Sensitive => MatchOptions::empty(),
8080
};
81-
todo!()
81+
false
8282
}
8383

8484
pub fn matches(&self, _value: &BStr, _options: MatchOptions) -> bool {

git-glob/tests/matching/mod.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ impl<'a> Baseline<'a> {
4444
#[ignore]
4545
fn compare_baseline_with_ours() {
4646
let dir = git_testtools::scripted_fixture_repo_read_only("make_baseline.sh").unwrap();
47+
let (mut total_matches, mut total_correct) = (0, 0);
4748
for (input_file, expected_matches) in &[("git-baseline.match", true), ("git-baseline.nmatch", false)] {
4849
let input = std::fs::read(dir.join(*input_file)).unwrap();
4950
let mut seen = BTreeSet::default();
@@ -54,24 +55,27 @@ fn compare_baseline_with_ours() {
5455
is_match,
5556
} in Baseline::new(&input)
5657
{
58+
total_matches += 1;
5759
assert!(seen.insert(m), "duplicate match entry: {:?}", m);
5860
assert_eq!(
5961
is_match, *expected_matches,
6062
"baseline for matches must indeed be {} - check baseline and git version: {:?}",
6163
expected_matches, m
6264
);
6365
let pattern = git_glob::Pattern::from_bytes(pattern).expect("parsing works");
64-
assert_eq!(
65-
pattern.matches_path(
66-
value,
67-
value.rfind_byte(b'/').map(|pos| pos + 1),
68-
false, // TODO: does it make sense to pretent it is a dir and see what happens?
69-
pattern::Case::Sensitive
70-
),
71-
is_match
72-
)
66+
let actual_match = pattern.matches_path(
67+
value,
68+
value.rfind_byte(b'/').map(|pos| pos + 1),
69+
false, // TODO: does it make sense to pretent it is a dir and see what happens?
70+
pattern::Case::Sensitive,
71+
);
72+
if actual_match == is_match {
73+
total_correct += 1;
74+
}
7375
}
7476
}
77+
78+
assert_eq!(total_correct, total_matches, "We perfectly agree with git here");
7579
}
7680

7781
#[test]

0 commit comments

Comments
 (0)