Implement basic lua test harness
This commit is contained in:
17
src/main.rs
17
src/main.rs
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user