feat: Add VM statistics and fix compilation errors for plugin tests
- Add VM instruction statistics (--vm-stats, --vm-stats-json) - Fix missing fields in ast.rs test code (public_fields, private_fields) - Add CliConfig fields for VM statistics - Enable TLV debug logging in plugin_loader_v2 - Successfully test FileBox handle passing and HTTP plugin creation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -121,6 +121,57 @@ f.close()
|
||||
assert_eq!(result.to_string_box().value, "void");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn e2e_vm_plugin_filebox_open_rw() {
|
||||
if !try_init_plugins() { return; }
|
||||
|
||||
// Open, write, read via VM backend
|
||||
let code = r#"
|
||||
local f, data
|
||||
f = new FileBox()
|
||||
f.open("./test_write.txt", "rw")
|
||||
f.write("HELLO")
|
||||
data = f.read()
|
||||
data
|
||||
"#;
|
||||
|
||||
let ast = NyashParser::parse_from_string(code).expect("parse failed");
|
||||
let runtime = NyashRuntime::new();
|
||||
let mut compiler = nyash_rust::mir::MirCompiler::new();
|
||||
let compile_result = compiler.compile(ast).expect("mir compile failed");
|
||||
let mut vm = VM::with_runtime(runtime);
|
||||
let result = vm.execute_module(&compile_result.module).expect("vm exec failed");
|
||||
assert_eq!(result.to_string_box().value, "HELLO");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn e2e_vm_plugin_filebox_copy_from_handle() {
|
||||
if !try_init_plugins() { return; }
|
||||
|
||||
let p1 = "./test_out_src.txt";
|
||||
let p2 = "./test_out_dst.txt";
|
||||
|
||||
let code = format!(r#"
|
||||
local a, b, data
|
||||
a = new FileBox()
|
||||
b = new FileBox()
|
||||
a.open("{}", "w")
|
||||
b.open("{}", "rw")
|
||||
a.write("HELLO")
|
||||
b.copyFrom(a)
|
||||
data = b.read()
|
||||
data
|
||||
"#, p1, p2);
|
||||
|
||||
let ast = NyashParser::parse_from_string(&code).expect("parse failed");
|
||||
let runtime = NyashRuntime::new();
|
||||
let mut compiler = nyash_rust::mir::MirCompiler::new();
|
||||
let compile_result = compiler.compile(ast).expect("mir compile failed");
|
||||
let mut vm = VM::with_runtime(runtime);
|
||||
let result = vm.execute_module(&compile_result.module).expect("vm exec failed");
|
||||
assert_eq!(result.to_string_box().value, "HELLO");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn e2e_interpreter_plugin_filebox_copy_from_handle() {
|
||||
if !try_init_plugins() { return; }
|
||||
|
||||
Reference in New Issue
Block a user