mirror of
https://github.com/slint-ui/slint.git
synced 2025-09-30 13:51:13 +00:00
Add support for checking diagnostics in imported files
This commit is contained in:
parent
8aa1c5ae1b
commit
14ad99fed4
1 changed files with 41 additions and 22 deletions
|
@ -56,32 +56,13 @@ fn process_file(path: &std::path::Path) -> std::io::Result<bool> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_file_source(
|
fn process_diagnostics(
|
||||||
path: &std::path::Path,
|
mut compile_diagnostics: sixtyfps_compilerlib::diagnostics::FileDiagnostics,
|
||||||
source: String,
|
source: String,
|
||||||
silent: bool,
|
silent: bool,
|
||||||
) -> std::io::Result<bool> {
|
) -> std::io::Result<bool> {
|
||||||
let (syntax_node, parse_diagnostics) =
|
|
||||||
sixtyfps_compilerlib::parser::parse(source.clone(), Some(path));
|
|
||||||
let mut compile_diagnostics = if !parse_diagnostics.has_error() {
|
|
||||||
let compiler_config = sixtyfps_compilerlib::CompilerConfiguration {
|
|
||||||
style: "ugly".into(),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let (_, build_diags) = sixtyfps_compilerlib::compile_syntax_node(
|
|
||||||
syntax_node,
|
|
||||||
parse_diagnostics,
|
|
||||||
&compiler_config,
|
|
||||||
);
|
|
||||||
build_diags.into_iter().collect()
|
|
||||||
} else {
|
|
||||||
vec![parse_diagnostics]
|
|
||||||
};
|
|
||||||
|
|
||||||
assert_eq!(compile_diagnostics.len(), 1);
|
|
||||||
let mut compile_diagnostics = compile_diagnostics.remove(0);
|
|
||||||
|
|
||||||
let mut success = true;
|
let mut success = true;
|
||||||
|
let path = compile_diagnostics.current_path.as_ref();
|
||||||
|
|
||||||
// Find expected errors in the file. The first caret (^) points to the expected column. The number of
|
// Find expected errors in the file. The first caret (^) points to the expected column. The number of
|
||||||
// carets refers to the number of lines to go back. This is useful when one line of code produces multiple
|
// carets refers to the number of lines to go back. This is useful when one line of code produces multiple
|
||||||
|
@ -150,6 +131,44 @@ fn process_file_source(
|
||||||
Ok(success)
|
Ok(success)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn process_file_source(
|
||||||
|
path: &std::path::Path,
|
||||||
|
source: String,
|
||||||
|
silent: bool,
|
||||||
|
) -> std::io::Result<bool> {
|
||||||
|
let (syntax_node, parse_diagnostics) =
|
||||||
|
sixtyfps_compilerlib::parser::parse(source.clone(), Some(path));
|
||||||
|
let compile_diagnostics = if !parse_diagnostics.has_error() {
|
||||||
|
let compiler_config = sixtyfps_compilerlib::CompilerConfiguration {
|
||||||
|
style: "ugly".into(),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let (_, build_diags) = sixtyfps_compilerlib::compile_syntax_node(
|
||||||
|
syntax_node,
|
||||||
|
parse_diagnostics,
|
||||||
|
&compiler_config,
|
||||||
|
);
|
||||||
|
build_diags.into_iter().collect()
|
||||||
|
} else {
|
||||||
|
vec![parse_diagnostics]
|
||||||
|
};
|
||||||
|
|
||||||
|
assert!(compile_diagnostics.len() >= 1);
|
||||||
|
|
||||||
|
let mut success = true;
|
||||||
|
|
||||||
|
for diagnostics in compile_diagnostics.into_iter() {
|
||||||
|
let source = if *diagnostics.current_path == path {
|
||||||
|
source.clone()
|
||||||
|
} else {
|
||||||
|
std::fs::read_to_string(diagnostics.current_path.as_ref())?
|
||||||
|
};
|
||||||
|
success &= process_diagnostics(diagnostics, source, silent)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(success)
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
/// Test that this actually fail when it should
|
/// Test that this actually fail when it should
|
||||||
fn self_test() -> std::io::Result<()> {
|
fn self_test() -> std::io::Result<()> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue