From 4ab3802eeeecc19a12a45787777f0d6d325c3bea Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 15 Mar 2021 19:51:04 +0100 Subject: [PATCH] Fix the documentation tests --- tests/doctests/main.rs | 39 +++++++++++++++++++-------------------- 1 file changed, 19 insertions(+), 20 deletions(-) diff --git a/tests/doctests/main.rs b/tests/doctests/main.rs index 216b3ea9b1f..61672df8017 100644 --- a/tests/doctests/main.rs +++ b/tests/doctests/main.rs @@ -10,28 +10,27 @@ LICENSE END */ #[cfg(test)] fn do_test(snippet: &str) -> Result<(), Box> { - let config = sixtyfps_compilerlib::CompilerConfiguration::new( - sixtyfps_compilerlib::generator::OutputFormat::Interpreter, - ); - - let (component, warnings) = match spin_on::spin_on(sixtyfps_interpreter::load( - snippet.into(), - Default::default(), - config, - )) { - (Ok(c), diagnostics) => (c, diagnostics), - (Err(()), errors) => { - let vec = errors.to_string_vec(); - errors.print(); - return Err(vec.join("\n").into()); + let config = sixtyfps_interpreter::CompilerConfiguration::new(); + let (component, diagnostics) = + spin_on::spin_on(sixtyfps_interpreter::ComponentDefinition::from_source( + snippet.into(), + Default::default(), + config, + )); + + sixtyfps_interpreter::print_diagnostics(&diagnostics); + + for d in diagnostics { + if d.level() == sixtyfps_interpreter::DiagnosticLevel::Error { + return Err(d.message().to_owned().into()); } - }; - - warnings.print(); - - component.create(); + } - Ok(()) + if component.is_none() { + Err(String::from("Failure").into()) + } else { + Ok(()) + } } include!(env!("TEST_FUNCTIONS"));