From 6ea4184fd107e5cc155b95a3cf058200c38d544d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 20 Aug 2019 18:53:59 +0300 Subject: translate \n -> \r\n on the way out --- crates/test_utils/src/lib.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'crates/test_utils') diff --git a/crates/test_utils/src/lib.rs b/crates/test_utils/src/lib.rs index ea99ac062..816d01f09 100644 --- a/crates/test_utils/src/lib.rs +++ b/crates/test_utils/src/lib.rs @@ -134,21 +134,25 @@ pub fn parse_fixture(fixture: &str) -> Vec { } }; }; + let margin = fixture .lines() .filter(|it| it.trim_start().starts_with("//-")) .map(|it| it.len() - it.trim_start().len()) .next() .expect("empty fixture"); - let lines = fixture.lines().filter_map(|line| { - if line.len() >= margin { - assert!(line[..margin].trim().is_empty()); - Some(&line[margin..]) - } else { - assert!(line.trim().is_empty()); - None - } - }); + + let lines = fixture + .split('\n') // don't use `.lines` to not drop `\r\n` + .filter_map(|line| { + if line.len() >= margin { + assert!(line[..margin].trim().is_empty()); + Some(&line[margin..]) + } else { + assert!(line.trim().is_empty()); + None + } + }); for line in lines { if line.starts_with("//-") { -- cgit v1.2.3