Extract the file to lines function

This commit is contained in:
Graham Christensen 2018-03-17 13:25:06 -04:00
parent 9420cb5c18
commit 29fadfaa4b
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C

View file

@ -291,6 +291,15 @@ mod tests {
Fail, Fail,
} }
fn lines_from_file(file: File) -> Vec<String> {
BufReader::new(file)
.lines()
.into_iter()
.filter(|line| line.is_ok())
.map(|line| line.unwrap())
.collect()
}
fn assert_run(res: Result<File, File>, expected: Expect, require: Vec<&str>) { fn assert_run(res: Result<File, File>, expected: Expect, require: Vec<&str>) {
let expectation_held: bool = match expected { let expectation_held: bool = match expected {
Expect::Pass => res.is_ok(), Expect::Pass => res.is_ok(),
@ -302,12 +311,7 @@ mod tests {
Err(file) => file, Err(file) => file,
}; };
let lines: Vec<String> = BufReader::new(file) let lines = lines_from_file(file);
.lines()
.into_iter()
.filter(|line| line.is_ok())
.map(|line| line.unwrap())
.collect();
let buildlog = lines let buildlog = lines
.into_iter() .into_iter()