From bb381a7ff7a21cad98d80005a81f2586684f80a0 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 3 Feb 2018 12:51:06 +0300 Subject: Move tools to a separate package --- tests/testutils/src/lib.rs | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) (limited to 'tests') diff --git a/tests/testutils/src/lib.rs b/tests/testutils/src/lib.rs index 80a94fb66..f829b243b 100644 --- a/tests/testutils/src/lib.rs +++ b/tests/testutils/src/lib.rs @@ -1,7 +1,7 @@ extern crate difference; extern crate file; -use std::path::{PathBuf, Path}; +use std::path::{Path, PathBuf}; use std::fs::read_dir; use difference::Changeset; @@ -21,12 +21,9 @@ fn read_text(path: &Path) -> String { file::get_text(path).unwrap().replace("\r\n", "\n") } -pub fn dir_tests( - paths: &[&str], - f: F -) +pub fn dir_tests(paths: &[&str], f: F) where - F: Fn(&str) -> String + F: Fn(&str) -> String, { for path in collect_tests(paths) { let actual = { @@ -47,21 +44,20 @@ where } } -fn assert_equal_text( - expected: &str, - actual: &str, - path: &Path -) { +fn assert_equal_text(expected: &str, actual: &str, path: &Path) { if expected != actual { print_difference(expected, actual, path) } } fn collect_tests(paths: &[&str]) -> Vec { - paths.iter().flat_map(|path| { - let path = test_data_dir().join(path); - test_from_dir(&path).into_iter() - }).collect() + paths + .iter() + .flat_map(|path| { + let path = test_data_dir().join(path); + test_from_dir(&path).into_iter() + }) + .collect() } fn test_from_dir(dir: &Path) -> Vec { @@ -95,11 +91,13 @@ fn print_difference(expected: &str, actual: &str, path: &Path) { fn project_dir() -> PathBuf { let dir = env!("CARGO_MANIFEST_DIR"); PathBuf::from(dir) - .parent().unwrap() - .parent().unwrap() + .parent() + .unwrap() + .parent() + .unwrap() .to_owned() } fn test_data_dir() -> PathBuf { project_dir().join("tests/data") -} \ No newline at end of file +} -- cgit v1.2.3 From 9435ea4b8e990521ee7a6206b6106bb3ce392746 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 3 Feb 2018 12:54:13 +0300 Subject: Drop unused extern crate --- tests/lexer.rs | 1 - tests/parser.rs | 1 - 2 files changed, 2 deletions(-) (limited to 'tests') diff --git a/tests/lexer.rs b/tests/lexer.rs index 397ebafdd..46ac9fedd 100644 --- a/tests/lexer.rs +++ b/tests/lexer.rs @@ -1,4 +1,3 @@ -extern crate file; extern crate libsyntax2; extern crate testutils; diff --git a/tests/parser.rs b/tests/parser.rs index 37c9021ef..f681c066f 100644 --- a/tests/parser.rs +++ b/tests/parser.rs @@ -1,4 +1,3 @@ -extern crate file; extern crate libsyntax2; extern crate testutils; -- cgit v1.2.3