Skip to content

Commit

Permalink
git-baseline now acts like a massive regression test (#301)
Browse files Browse the repository at this point in the history
Thus it will only keep a failure count, which we try to boost to 100%
over time.
  • Loading branch information
Byron committed Apr 9, 2022
1 parent b947ff9 commit fe3d0a7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
2 changes: 1 addition & 1 deletion git-glob/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub mod pattern {
Case::Fold => MatchOptions::IGNORE_CASE,
Case::Sensitive => MatchOptions::empty(),
};
todo!()
false
}

pub fn matches(&self, _value: &BStr, _options: MatchOptions) -> bool {
Expand Down
22 changes: 13 additions & 9 deletions git-glob/tests/matching/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ impl<'a> Baseline<'a> {
#[ignore]
fn compare_baseline_with_ours() {
let dir = git_testtools::scripted_fixture_repo_read_only("make_baseline.sh").unwrap();
let (mut total_matches, mut total_correct) = (0, 0);
for (input_file, expected_matches) in &[("git-baseline.match", true), ("git-baseline.nmatch", false)] {
let input = std::fs::read(dir.join(*input_file)).unwrap();
let mut seen = BTreeSet::default();
Expand All @@ -54,24 +55,27 @@ fn compare_baseline_with_ours() {
is_match,
} in Baseline::new(&input)
{
total_matches += 1;
assert!(seen.insert(m), "duplicate match entry: {:?}", m);
assert_eq!(
is_match, *expected_matches,
"baseline for matches must indeed be {} - check baseline and git version: {:?}",
expected_matches, m
);
let pattern = git_glob::Pattern::from_bytes(pattern).expect("parsing works");
assert_eq!(
pattern.matches_path(
value,
value.rfind_byte(b'/').map(|pos| pos + 1),
false, // TODO: does it make sense to pretent it is a dir and see what happens?
pattern::Case::Sensitive
),
is_match
)
let actual_match = pattern.matches_path(
value,
value.rfind_byte(b'/').map(|pos| pos + 1),
false, // TODO: does it make sense to pretent it is a dir and see what happens?
pattern::Case::Sensitive,
);
if actual_match == is_match {
total_correct += 1;
}
}
}

assert_eq!(total_correct, total_matches, "We perfectly agree with git here");
}

#[test]
Expand Down

0 comments on commit fe3d0a7

Please sign in to comment.