From bbc09d65ce206d78ac7b8cfc32cc5ed4dec5fbfe Mon Sep 17 00:00:00 2001 From: Nadrieril Date: Sat, 13 Apr 2019 19:31:50 +0200 Subject: Improve error display on test failure --- dhall/src/tests.rs | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) (limited to 'dhall') diff --git a/dhall/src/tests.rs b/dhall/src/tests.rs index 57d3deb..4343341 100644 --- a/dhall/src/tests.rs +++ b/dhall/src/tests.rs @@ -24,16 +24,7 @@ macro_rules! make_spec_test { #[allow(non_snake_case)] fn $name() { use crate::tests::*; - // Many tests stack overflow in debug mode - std::thread::Builder::new() - .stack_size(4 * 1024 * 1024) - .spawn(|| { - run_test($path, Feature::$type, Status::$status) - .map_err(|e| println!("{}", e)) - .unwrap(); - }) - .unwrap() - .join() + run_test_with_bigger_stack($path, Feature::$type, Status::$status) .unwrap(); } }; @@ -66,6 +57,25 @@ fn parse_binary_file_str<'i>(file_path: &str) -> Result { Parsed::parse_binary_file(&PathBuf::from(file_path)) } +pub fn run_test_with_bigger_stack( + base_path: &str, + feature: Feature, + status: Status, +) -> std::result::Result<(), String> { + // Many tests stack overflow in debug mode + let base_path: String = base_path.to_string(); + std::thread::Builder::new() + .stack_size(4 * 1024 * 1024) + .spawn(move || { + run_test(&base_path, feature, status) + .map_err(|e| e.to_string()) + .map(|_| ()) + }) + .unwrap() + .join() + .unwrap() +} + pub fn run_test( base_path: &str, feature: Feature, -- cgit v1.2.3