From 1525dd9f819b310a48657d3bbfd748bd3bd23239 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Wed, 10 Mar 2021 07:55:57 +0100 Subject: Test lua function mapping --- src/testbench.rs | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/testbench.rs b/src/testbench.rs index 9de4db1..6d9ea16 100644 --- a/src/testbench.rs +++ b/src/testbench.rs @@ -28,6 +28,13 @@ impl Test { return self.text.as_ref().unwrap(); } + + pub fn text(&self) -> &str { + return match &self.text { + Some(text) => text, + None => "", + } + } } #[derive(Default)] @@ -46,10 +53,15 @@ impl Bench { let lua_setup = lua.context(|context| -> rlua::Result<()> { use rlua::{String, Variadic}; + let globals = context.globals(); + let ui_table = context.create_table()?; - let ui_print = context.create_function(|_, strings: Variadic| Ok(()))?; + let ui_print = context.create_function(|_, strings: Variadic| { + Ok(()) + })?; ui_table.set("print", ui_print)?; + globals.set("ui", ui_table)?; Ok(()) }); @@ -66,16 +78,14 @@ impl Bench { }; // TODO: set graphically and use RV - b.load_tests("lua"); + b.load_tests(); return b; } - pub fn load_tests

(&mut self, path: P) -> io::Result<()> - where - P: AsRef, + pub fn load_tests(&mut self) -> io::Result<()> { - let entries: Result, io::Error> = fs::read_dir(path)? + let entries: Result, io::Error> = fs::read_dir(&self.tests_path)? .into_iter() .map(|r| r.map(|f| f.path())) .collect(); -- cgit v1.2.1