Fix tests after diff bump; drive-by prettify diff tests (#56)

This commit is contained in:
kyegupov 2017-12-17 16:14:39 +00:00 committed by Magnus Hoff
parent 6e3f1dab07
commit 8b838ac8c9
4 changed files with 110 additions and 24 deletions

44
Cargo.lock generated
View file

@ -319,6 +319,26 @@ dependencies = [
"unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-normalization 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
] ]
[[package]]
name = "indoc"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"indoc-impl 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"proc-macro-hack 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "indoc-impl"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro-hack 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)",
"syn 0.11.11 (registry+https://github.com/rust-lang/crates.io-index)",
"unindent 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]] [[package]]
name = "infer_schema_internals" name = "infer_schema_internals"
version = "1.0.0-beta1" version = "1.0.0-beta1"
@ -554,6 +574,19 @@ name = "pkg-config"
version = "0.3.9" version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "proc-macro-hack"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"proc-macro-hack-impl 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "proc-macro-hack-impl"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "pulldown-cmark" name = "pulldown-cmark"
version = "0.1.0" version = "0.1.0"
@ -663,6 +696,7 @@ dependencies = [
"futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)", "futures 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)",
"futures-cpupool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "futures-cpupool 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.11.9 (registry+https://github.com/rust-lang/crates.io-index)", "hyper 0.11.9 (registry+https://github.com/rust-lang/crates.io-index)",
"indoc 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "lazy_static 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libsqlite3-sys 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)", "libsqlite3-sys 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
"maplit 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", "maplit 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)",
@ -955,6 +989,11 @@ name = "unidecode"
version = "0.2.0" version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "unindent"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "unreachable" name = "unreachable"
version = "1.0.0" version = "1.0.0"
@ -1067,6 +1106,8 @@ dependencies = [
"checksum httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "af2f2dd97457e8fb1ae7c5a420db346af389926e36f43768b96f101546b04a07" "checksum httparse 1.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "af2f2dd97457e8fb1ae7c5a420db346af389926e36f43768b96f101546b04a07"
"checksum hyper 0.11.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e0594792d2109069d0caffd176f674d770a84adf024c5bb48e686b1ee5ac7659" "checksum hyper 0.11.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e0594792d2109069d0caffd176f674d770a84adf024c5bb48e686b1ee5ac7659"
"checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d" "checksum idna 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "014b298351066f1512874135335d62a789ffe78a9974f94b43ed5621951eaf7d"
"checksum indoc 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "1728ee8a2e45f6dc2843585160d1c7c14950abd3f9d23f854b9b2d6ff8b2379e"
"checksum indoc-impl 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a4d87d10be98219365f73f997c1c3a0b12c7be2c6b505211c9b062bd23763aae"
"checksum infer_schema_internals 1.0.0-beta1 (registry+https://github.com/rust-lang/crates.io-index)" = "612223b7e3f3d91f2e37007140001c110611672024ffa20e8d0a2e650e01fb3d" "checksum infer_schema_internals 1.0.0-beta1 (registry+https://github.com/rust-lang/crates.io-index)" = "612223b7e3f3d91f2e37007140001c110611672024ffa20e8d0a2e650e01fb3d"
"checksum infer_schema_macros 1.0.0-beta1 (registry+https://github.com/rust-lang/crates.io-index)" = "ee7447ac27f01f224a6fae696480a803a5c5779971b254d728c3486885198677" "checksum infer_schema_macros 1.0.0-beta1 (registry+https://github.com/rust-lang/crates.io-index)" = "ee7447ac27f01f224a6fae696480a803a5c5779971b254d728c3486885198677"
"checksum iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6e8b9c2247fcf6c6a1151f1156932be5606c9fd6f55a2d7f9fc1cb29386b2f7" "checksum iovec 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b6e8b9c2247fcf6c6a1151f1156932be5606c9fd6f55a2d7f9fc1cb29386b2f7"
@ -1098,6 +1139,8 @@ dependencies = [
"checksum num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "514f0d73e64be53ff320680ca671b64fe3fb91da01e1ae2ddc99eb51d453b20d" "checksum num_cpus 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "514f0d73e64be53ff320680ca671b64fe3fb91da01e1ae2ddc99eb51d453b20d"
"checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831" "checksum percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "31010dd2e1ac33d5b46a5b413495239882813e0369f8ed8a5e266f173602f831"
"checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903" "checksum pkg-config 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "3a8b4c6b8165cd1a1cd4b9b120978131389f64bdaf456435caa41e630edba903"
"checksum proc-macro-hack 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3ba8d4f9257b85eb6cdf13f055cea3190520aab1409ca2ab43493ea4820c25f0"
"checksum proc-macro-hack-impl 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d5cb6f960ad471404618e9817c0e5d10b1ae74cfdf01fab89ea0641fe7fb2892"
"checksum pulldown-cmark 0.1.0 (git+https://github.com/maghoff/pulldown-cmark.git)" = "<none>" "checksum pulldown-cmark 0.1.0 (git+https://github.com/maghoff/pulldown-cmark.git)" = "<none>"
"checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a" "checksum quote 0.3.15 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e920b65c65f10b2ae65c831a81a073a89edd28c7cce89475bff467ab4167a"
"checksum r2d2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "59611202bee496c586ecd84e3ed149b4ec75981b0fc10d7f60e878fa23ae16e9" "checksum r2d2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "59611202bee496c586ecd84e3ed149b4ec75981b0fc10d7f60e878fa23ae16e9"
@ -1143,6 +1186,7 @@ dependencies = [
"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" "checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f"
"checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc" "checksum unicode-xid 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f860d7d29cf02cb2f3f359fd35991af3d30bac52c57d265a3c461074cb4dc"
"checksum unidecode 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2adb95ee07cd579ed18131f2d9e7a17c25a4b76022935c7f2460d2bfae89fd2" "checksum unidecode 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d2adb95ee07cd579ed18131f2d9e7a17c25a4b76022935c7f2460d2bfae89fd2"
"checksum unindent 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "10743f62eafa8863b3dbb35cd6abbb609c963dd98940142a85bc530b753e33a4"
"checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56" "checksum unreachable 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "382810877fe448991dfc7f0dd6e3ae5d58088fd0ea5e35189655f84e6814fa56"
"checksum url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa35e768d4daf1d85733418a49fb42e10d7f633e394fccab4ab7aba897053fe2" "checksum url 1.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "fa35e768d4daf1d85733418a49fb42e10d7f633e394fccab4ab7aba897053fe2"
"checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122" "checksum utf8-ranges 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "662fab6525a98beff2921d7f61a39e7d59e0b425ebc7d0d9e66d316e55124122"

View file

@ -9,6 +9,7 @@ license = "GPL-3.0"
panic = "abort" panic = "abort"
[dev-dependencies] [dev-dependencies]
indoc = "0.2"
matches = "0.1" matches = "0.1"
[dependencies] [dependencies]

View file

@ -1,6 +1,7 @@
#![recursion_limit="128"] // for diesel's infer_schema! #![recursion_limit="128"] // for diesel's infer_schema!
#[cfg(test)] #[macro_use] extern crate matches; #[cfg(test)] #[macro_use] extern crate matches;
#[cfg(test)] #[macro_use] extern crate indoc;
#[macro_use] extern crate bart_derive; #[macro_use] extern crate bart_derive;
#[macro_use] extern crate codegen; #[macro_use] extern crate codegen;

View file

@ -95,8 +95,8 @@ pub fn merge_lines<'a>(a: &'a str, o: &'a str, b: &'a str) -> MergeResult<&'a st
Resolved(y) => y.into_iter(), Resolved(y) => y.into_iter(),
_ => unreachable!() _ => unreachable!()
}) })
.flat_map(|x| vec![x, "\n"].into_iter()) .collect::<Vec<_>>()
.collect() .join("\n")
) )
} else { } else {
MergeResult::Conflicted(hunks) MergeResult::Conflicted(hunks)
@ -160,16 +160,30 @@ mod test {
#[test] #[test]
fn clean_case() { fn clean_case() {
assert_eq!(MergeResult::Clean("\ assert_eq!(MergeResult::Clean(indoc!("
aaa\n\ aaa
xxx\n\ xxx
bbb\n\ bbb
yyy\n\ yyy
ccc\n\ ccc
".into()), merge_lines( ").into()), merge_lines(
"aaa\nxxx\nbbb\nccc\n", indoc!("
"aaa\nbbb\nccc\n", aaa
"aaa\nbbb\nyyy\nccc\n", xxx
bbb
ccc
"),
indoc!("
aaa
bbb
ccc
"),
indoc!("
aaa
bbb
yyy
ccc
"),
)); ));
} }
@ -184,14 +198,26 @@ mod test {
#[test] #[test]
fn false_conflict() { fn false_conflict() {
assert_eq!(MergeResult::Clean("\ assert_eq!(MergeResult::Clean(indoc!("
aaa\n\ aaa
xxx\n\ xxx
ccc\n\ ccc
".into()), merge_lines( ").into()), merge_lines(
"aaa\nxxx\nccc\n", indoc!("
"aaa\nbbb\nccc\n", aaa
"aaa\nxxx\nccc\n", xxx
ccc
"),
indoc!("
aaa
bbb
ccc
"),
indoc!("
aaa
xxx
ccc
"),
)); ));
} }
@ -200,11 +226,25 @@ mod test {
assert_eq!(MergeResult::Conflicted(vec![ assert_eq!(MergeResult::Conflicted(vec![
Resolved(vec!["aaa"]), Resolved(vec!["aaa"]),
Conflict(vec!["xxx"], vec![], vec!["yyy"]), Conflict(vec!["xxx"], vec![], vec!["yyy"]),
Resolved(vec!["bbb", "ccc"]), Resolved(vec!["bbb", "ccc", ""]),
]), merge_lines( ]), merge_lines(
"aaa\nxxx\nbbb\nccc\n", indoc!("
"aaa\nbbb\nccc\n", aaa
"aaa\nyyy\nbbb\nccc\n", xxx
bbb
ccc
"),
indoc!("
aaa
bbb
ccc
"),
indoc!("
aaa
yyy
bbb
ccc
"),
)); ));
} }
} }