Ignore can errors in glue tests

This commit is contained in:
Ayaz Hafiz 2022-09-28 14:59:15 -05:00
parent 066474bfde
commit 1cffb3376e
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 22 additions and 4 deletions

View file

@ -12,8 +12,20 @@ use std::process;
use strum::IntoEnumIterator; use strum::IntoEnumIterator;
use target_lexicon::Triple; use target_lexicon::Triple;
pub struct IgnoreErrors {
pub can: bool,
}
impl IgnoreErrors {
const NONE: Self = IgnoreErrors { can: false };
}
pub fn generate(input_path: &Path, output_path: &Path) -> io::Result<i32> { pub fn generate(input_path: &Path, output_path: &Path) -> io::Result<i32> {
match load_types(input_path.to_path_buf(), Threading::AllAvailable) { match load_types(
input_path.to_path_buf(),
Threading::AllAvailable,
IgnoreErrors::NONE,
) {
Ok(types_and_targets) => { Ok(types_and_targets) => {
let mut file = File::create(output_path).unwrap_or_else(|err| { let mut file = File::create(output_path).unwrap_or_else(|err| {
eprintln!( eprintln!(
@ -67,6 +79,7 @@ pub fn generate(input_path: &Path, output_path: &Path) -> io::Result<i32> {
pub fn load_types( pub fn load_types(
full_file_path: PathBuf, full_file_path: PathBuf,
threading: Threading, threading: Threading,
ignore_errors: IgnoreErrors,
) -> Result<Vec<(Types, TargetInfo)>, io::Error> { ) -> Result<Vec<(Types, TargetInfo)>, io::Error> {
let target_info = (&Triple::host()).into(); let target_info = (&Triple::host()).into();
@ -108,7 +121,7 @@ pub fn load_types(
let can_problems = can_problems.remove(&home).unwrap_or_default(); let can_problems = can_problems.remove(&home).unwrap_or_default();
let type_problems = type_problems.remove(&home).unwrap_or_default(); let type_problems = type_problems.remove(&home).unwrap_or_default();
if !can_problems.is_empty() || !type_problems.is_empty() { if (!ignore_errors.can && !can_problems.is_empty()) || !type_problems.is_empty() {
todo!( todo!(
"Gracefully report compilation problems during glue generation: {:?}, {:?}", "Gracefully report compilation problems during glue generation: {:?}, {:?}",
can_problems, can_problems,

View file

@ -1,4 +1,4 @@
use roc_glue::load::load_types; use roc_glue::load::{load_types, IgnoreErrors};
use roc_glue::rust_glue; use roc_glue::rust_glue;
use roc_load::Threading; use roc_load::Threading;
use std::env; use std::env;
@ -33,7 +33,12 @@ pub fn generate_bindings(decl_src: &str) -> String {
let mut file = File::create(file_path).unwrap(); let mut file = File::create(file_path).unwrap();
writeln!(file, "{}", &src).unwrap(); writeln!(file, "{}", &src).unwrap();
let result = load_types(full_file_path, Threading::Single); let result = load_types(
full_file_path,
Threading::Single,
// required `nothing` is unused; that error is okay
IgnoreErrors { can: true },
);
dir.close().expect("Unable to close tempdir"); dir.close().expect("Unable to close tempdir");