mirror of
https://github.com/fluencelabs/lalrpop
synced 2025-03-28 06:01:02 +00:00
Print out the first N lines that mismatched in the snapshot.
This commit is contained in:
parent
c8df49872d
commit
66158dada1
@ -940,8 +940,9 @@ fn verify_lalrpop_generates_itself() {
|
|||||||
|
|
||||||
let actual = fs::read_to_string(grammar_file.with_extension("rs")).unwrap();
|
let actual = fs::read_to_string(grammar_file.with_extension("rs")).unwrap();
|
||||||
let expected = fs::read_to_string(copied_grammar_file.with_extension("rs")).unwrap();
|
let expected = fs::read_to_string(copied_grammar_file.with_extension("rs")).unwrap();
|
||||||
assert!(
|
util::compare_str(
|
||||||
actual == expected,
|
&actual,
|
||||||
|
&expected,
|
||||||
"The snapshot does not match what lalrpop generates now.\n\
|
"The snapshot does not match what lalrpop generates now.\n\
|
||||||
Use ./snap.sh to generate a new snapshot of the lrgrammar",
|
Use ./snap.sh to generate a new snapshot of the lrgrammar",
|
||||||
);
|
);
|
||||||
|
@ -84,7 +84,15 @@ pub fn compare<D: Debug, E: Debug>(actual: D, expected: E) {
|
|||||||
let actual_s = format!("{:#?}", actual);
|
let actual_s = format!("{:#?}", actual);
|
||||||
let expected_s = format!("{:#?}", expected);
|
let expected_s = format!("{:#?}", expected);
|
||||||
|
|
||||||
for diff in diff::lines(&actual_s, &expected_s) {
|
compare_str(&actual_s, &expected_s, "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn compare_str(actual: &str, expected: &str, msg: &str) {
|
||||||
|
if actual != expected {
|
||||||
|
let mut lines = 0;
|
||||||
|
for diff in diff::lines(actual, expected).into_iter().take(100) {
|
||||||
|
lines += 1;
|
||||||
match diff {
|
match diff {
|
||||||
diff::Result::Right(r) => println!("- {}", r),
|
diff::Result::Right(r) => println!("- {}", r),
|
||||||
diff::Result::Left(l) => println!("+ {}", l),
|
diff::Result::Left(l) => println!("+ {}", l),
|
||||||
@ -92,6 +100,9 @@ pub fn compare<D: Debug, E: Debug>(actual: D, expected: E) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
assert!(false);
|
if lines >= 100 {
|
||||||
|
println!("... more");
|
||||||
|
}
|
||||||
|
assert!(false, "{}", msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user