slint/tests/driver/interpreter.rs
Simon Hausmann cb081a6bda Test that loading types from the include path works
This uses the recently added "hooks" or APIs to pass an include path that's specified in the test case itself.
2020-07-19 18:31:10 +02:00

23 lines
641 B
Rust

use std::error::Error;
pub fn test(testcase: &test_driver_lib::TestCase) -> Result<(), Box<dyn Error>> {
let source = std::fs::read_to_string(&testcase.absolute_path)?;
let include_paths = &test_driver_lib::extract_include_paths(&source)
.map(std::path::PathBuf::from)
.collect::<Vec<_>>();
let component = match sixtyfps_interpreter::load(source, &testcase.absolute_path, include_paths)
{
Ok(c) => c,
Err(diag) => {
let vec = diag.to_string_vec();
diag.print();
return Err(vec.join("\n").into());
}
};
component.create();
Ok(())
}