diff options
author | Aleksey Kladov <[email protected]> | 2019-08-20 16:53:59 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-08-20 17:53:05 +0100 |
commit | 6ea4184fd107e5cc155b95a3cf058200c38d544d (patch) | |
tree | ca8cd031e10e64149e3fa6dc2ab0b53833b0b398 /crates/test_utils | |
parent | 80a6e614465d8b16cae50f3626c15e912ad3c6f2 (diff) |
translate \n -> \r\n on the way out
Diffstat (limited to 'crates/test_utils')
-rw-r--r-- | crates/test_utils/src/lib.rs | 22 |
1 files changed, 13 insertions, 9 deletions
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<FixtureEntry> { | |||
134 | } | 134 | } |
135 | }; | 135 | }; |
136 | }; | 136 | }; |
137 | |||
137 | let margin = fixture | 138 | let margin = fixture |
138 | .lines() | 139 | .lines() |
139 | .filter(|it| it.trim_start().starts_with("//-")) | 140 | .filter(|it| it.trim_start().starts_with("//-")) |
140 | .map(|it| it.len() - it.trim_start().len()) | 141 | .map(|it| it.len() - it.trim_start().len()) |
141 | .next() | 142 | .next() |
142 | .expect("empty fixture"); | 143 | .expect("empty fixture"); |
143 | let lines = fixture.lines().filter_map(|line| { | 144 | |
144 | if line.len() >= margin { | 145 | let lines = fixture |
145 | assert!(line[..margin].trim().is_empty()); | 146 | .split('\n') // don't use `.lines` to not drop `\r\n` |
146 | Some(&line[margin..]) | 147 | .filter_map(|line| { |
147 | } else { | 148 | if line.len() >= margin { |
148 | assert!(line.trim().is_empty()); | 149 | assert!(line[..margin].trim().is_empty()); |
149 | None | 150 | Some(&line[margin..]) |
150 | } | 151 | } else { |
151 | }); | 152 | assert!(line.trim().is_empty()); |
153 | None | ||
154 | } | ||
155 | }); | ||
152 | 156 | ||
153 | for line in lines { | 157 | for line in lines { |
154 | if line.starts_with("//-") { | 158 | if line.starts_with("//-") { |