Skip to content

Commit 5e4ee9b

Browse files
committed
run the baseline test and gather some information (#450)
1 parent 9c5fed2 commit 5e4ee9b

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
version https://git-lfs.github.com/spec/v1
2-
oid sha256:0a85fe0b4d9fb179baab26ea008ddbb48a657d4e92561c42a213269468481a66
3-
size 9308
2+
oid sha256:5aac946f32882b76ca1a1d980cdd56fb812e9059ba59074ef141dd0bb4b32903
3+
size 9320

git-refspec/tests/parse/mod.rs

+42-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,49 @@
1+
use bstr::ByteSlice;
2+
use git_refspec::Operation;
13
use git_testtools::scripted_fixture_repo_read_only;
4+
use std::panic::catch_unwind;
25

36
#[test]
4-
#[ignore]
7+
#[should_panic]
58
fn baseline() {
6-
let _dir = scripted_fixture_repo_read_only("make_baseline.sh").unwrap();
9+
let dir = scripted_fixture_repo_read_only("make_baseline.sh").unwrap();
10+
let baseline = std::fs::read(dir.join("baseline.git")).unwrap();
11+
let mut lines = baseline.lines();
12+
let mut panics = 0;
13+
let mut mismatch = 0;
14+
let mut count = 0;
15+
while let Some(kind_spec) = lines.next() {
16+
count += 1;
17+
let (kind, spec) = kind_spec.split_at(kind_spec.find_byte(b' ').expect("space between kind and spec"));
18+
let err_code: usize = lines
19+
.next()
20+
.expect("err code")
21+
.to_str()
22+
.unwrap()
23+
.parse()
24+
.expect("number");
25+
let op = match kind {
26+
b"fetch" => Operation::Fetch,
27+
b"push" => Operation::Push,
28+
_ => unreachable!("{} unexpected", kind.as_bstr()),
29+
};
30+
let res = catch_unwind(|| try_parse(spec.to_str().unwrap(), op));
31+
match res {
32+
Ok(res) => match (res.is_ok(), err_code == 0) {
33+
(true, true) | (false, false) => {}
34+
_ => mismatch += 1,
35+
},
36+
Err(_) => {
37+
panics += 1;
38+
}
39+
}
40+
}
41+
if panics != 0 || mismatch != 0 {
42+
panic!(
43+
"Out of {} baseline entries, got {} mismatches and {} panics",
44+
count, mismatch, panics
45+
);
46+
}
747
}
848

949
mod invalid {

0 commit comments

Comments
 (0)