Skip to content

Commit 7bc26d9

Browse files
committed
testing host_bindgen changes
Signed-off-by: Shailesh Vashishth <shavashishth@gmail.com>
1 parent 6e8b305 commit 7bc26d9

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

src/hyperlight_component_macro/src/lib.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,6 @@ impl Parse for BindgenInputParams {
166166
path = Some(std::path::PathBuf::from(concrete_path.value()));
167167
}
168168
}
169-
if world_name.is_some() && path.is_none() {
170-
return Err(syn::Error::new(
171-
proc_macro2::Span::call_site(),
172-
"If `world_name` is provided in the brace syntax, `path` must also be provided.",
173-
));
174-
}
175169
Ok(Self { world_name, path })
176170
}
177171
}

src/hyperlight_component_util/src/util.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ pub fn read_wit_type_from_file<R, F: FnMut(String, &etypes::Component) -> R>(
3131

3232
let bytes = std::fs::read(path).unwrap();
3333
let i = wasmparser::Parser::new(0).parse_all(&bytes);
34-
// let ct = crate::component::read_component_single_exported_type(i);
3534
let ct = crate::component::read_component_single_exported_type(i, world_name);
3635

3736
// because of the two-level encapsulation scheme, we need to look
@@ -63,7 +62,7 @@ pub fn emit_decls(decls: proc_macro2::TokenStream) -> proc_macro2::TokenStream {
6362
let decls = format!("{}", &decls);
6463
std::fs::write(&dbg_out, &decls).unwrap();
6564
}
66-
decls
65+
quote::quote! { include!(#dbg_out); }
6766
} else {
6867
decls
6968
}

src/hyperlight_host/tests/wit_test.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ mod wit_test {
430430
mod pick_world_bindings {
431431
hyperlight_component_macro::host_bindgen!({path: "../tests/rust_guests/witguest/twoworlds.wasm", world_name: "firstworld"});
432432
}
433-
434433
mod pick_world_binding_test {
435434
use crate::pick_world_bindings::r#twoworlds::r#wit::r#first_import::RecFirstImport;
436435

@@ -450,3 +449,26 @@ mod pick_world_binding_test {
450449
assert_eq!(first_import.r#value, "dummyValue");
451450
}
452451
}
452+
453+
mod pick_world_bindings2 {
454+
hyperlight_component_macro::host_bindgen!({path: "../tests/rust_guests/witguest/twoworlds.wasm", world_name: "secondworld"});
455+
}
456+
mod pick_world_binding_test {
457+
use crate::pick_world_bindings2::r#twoworlds::r#wit::r#second_export::RecSecondExport;
458+
459+
impl crate::pick_world_bindings2::r#twoworlds::r#wit::r#second_export::RecSecondExport {
460+
fn new() -> Self {
461+
Self {
462+
r#key: String::from("dummyKey"),
463+
r#value: String::from("dummyValue"),
464+
}
465+
}
466+
}
467+
468+
#[test]
469+
fn test_first_import_instance() {
470+
let first_import = RecSecondExport::new();
471+
assert_eq!(first_import.r#key, "dummyKey");
472+
assert_eq!(first_import.r#value, "dummyValue");
473+
}
474+
}

0 commit comments

Comments
 (0)