From 777625be21aefb28f10aef6cf966f48e1c10bdcc Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 24 May 2022 10:49:36 -0400 Subject: [PATCH] Cover all architecture variations in gen_rs tests --- bindgen/tests/gen_rs.rs | 5 +++++ bindgen/tests/helpers/mod.rs | 14 +++----------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/bindgen/tests/gen_rs.rs b/bindgen/tests/gen_rs.rs index 7521dcce92..cb6a1b8147 100644 --- a/bindgen/tests/gen_rs.rs +++ b/bindgen/tests/gen_rs.rs @@ -107,6 +107,11 @@ mod test_gen_rs { .unwrap_or_default(), indoc!( r#" + #[cfg(any( + target_arch = "x86_64", + target_arch = "aarch64", + target_arch = "arm" + ))] #[derive(Clone, Debug, Default, PartialEq, PartialOrd)] #[repr(C)] pub struct R1 { diff --git a/bindgen/tests/helpers/mod.rs b/bindgen/tests/helpers/mod.rs index e9aad3c1cd..93624e6956 100644 --- a/bindgen/tests/helpers/mod.rs +++ b/bindgen/tests/helpers/mod.rs @@ -1,7 +1,6 @@ use roc_bindgen::bindgen_rs; use roc_bindgen::load::load_types; use roc_load::Threading; -use roc_target::Architecture; use std::env; use std::fs::File; use std::io::Write; @@ -26,9 +25,7 @@ pub fn generate_bindings(decl_src: &str) -> String { src.push_str(decl_src); - // Only use the X86_64 types for these tests - let target_arch = Architecture::X86_64; - let types = { + let pairs = { let dir = tempdir().expect("Unable to create tempdir"); let filename = PathBuf::from("Package-Config.roc"); let file_path = dir.path().join(filename); @@ -41,14 +38,9 @@ pub fn generate_bindings(decl_src: &str) -> String { dir.close().expect("Unable to close tempdir"); result.expect("had problems loading") - } - .iter() - .find(|(architecture, _)| *architecture == target_arch) - .unwrap() - .1 - .clone(); + }; - bindgen_rs::emit(&[(target_arch, types)]) + bindgen_rs::emit(&pairs) } #[allow(dead_code)]