Implement basic lua test harness

This commit is contained in:
2025-06-27 03:11:49 +10:00
parent db4faea821
commit 40829cdfc6
5 changed files with 157 additions and 11 deletions

View File

@@ -219,17 +219,14 @@ fn init_tokio(args: &Args) -> tokio::runtime::Runtime {
fn init_lua(args: &Args) -> lb::runtime::Runtime {
let mut rt = {
let mut rt = lb::runtime::Builder::new();
rt.unhandled_error(error_cb);
luby::open(&mut rt);
if args.dump.iter().find(|s| *s == "cdef").is_some() {
print!("{}", rt.registry()); // for debugging
print!("{}", rt.registry()); // for cdef debugging
}
rt
}
.build()
.unwrap();
rt.unhandled_error(error_cb).build().unwrap()
};
for arg in args.jit.iter() {
let mut s = rt.guard();
@@ -281,10 +278,10 @@ async fn main_async(args: Args, cx: &mut lb::runtime::Context) -> Result<(), Exi
}
};
if let Err(err) = cx.load(&luajit::Chunk::new(chunk).path(path)) {
cx.report_error(&err);
} else if let Err(err) = cx.call_async(0, 0).await {
cx.report_error(&err);
if let Err(ref err) = cx.load(&luajit::Chunk::new(chunk).path(path)) {
cx.report_error(err);
} else if let Err(ref err) = cx.call_async(0, 0).await {
cx.report_error(err);
}
}