From 333e140a50658151002c9287aa68855358bedd56 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 30 Jul 2018 15:25:52 +0300 Subject: Mior --- tests/testutils/src/lib.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'tests/testutils/src') diff --git a/tests/testutils/src/lib.rs b/tests/testutils/src/lib.rs index 43b806541..7c481156f 100644 --- a/tests/testutils/src/lib.rs +++ b/tests/testutils/src/lib.rs @@ -1,8 +1,9 @@ extern crate difference; -extern crate file; -use std::fs::read_dir; -use std::path::{Path, PathBuf}; +use std::{ + fs, + path::{Path, PathBuf} +}; use difference::Changeset; @@ -18,7 +19,7 @@ use difference::Changeset; /// /// so this should always be correct. fn read_text(path: &Path) -> String { - file::get_text(path).unwrap().replace("\r\n", "\n") + fs::read_to_string(path).unwrap().replace("\r\n", "\n") } pub fn dir_tests(paths: &[&str], f: F) @@ -33,7 +34,7 @@ where println!("\nfile: {}", path.display()); println!("No .txt file with expected result, creating...\n"); println!("{}\n{}", input_code, parse_tree); - file::put_text(&path, parse_tree).unwrap(); + fs::write(&path, parse_tree).unwrap(); panic!("No expected result") } let expected = read_text(&path); @@ -61,7 +62,7 @@ fn collect_tests(paths: &[&str]) -> Vec { fn test_from_dir(dir: &Path) -> Vec { let mut acc = Vec::new(); - for file in read_dir(&dir).unwrap() { + for file in fs::read_dir(&dir).unwrap() { let file = file.unwrap(); let path = file.path(); if path.extension().unwrap_or_default() == "rs" { @@ -80,12 +81,12 @@ fn print_difference(expected: &str, actual: &str, path: &Path) { if expected.trim() == actual.trim() { println!("whitespace difference, rewriting"); println!("file: {}\n", path.display()); - file::put_text(path, actual).unwrap(); + fs::write(path, actual).unwrap(); return; } if REWRITE { println!("rewriting {}", path.display()); - file::put_text(path, actual).unwrap(); + fs::write(path, actual).unwrap(); return; } let changeset = Changeset::new(actual, expected, "\n"); -- cgit v1.2.3