diff options
author | Nao Pross <np@0hm.ch> | 2021-03-10 07:55:57 +0100 |
---|---|---|
committer | Nao Pross <np@0hm.ch> | 2021-03-10 07:55:57 +0100 |
commit | 1525dd9f819b310a48657d3bbfd748bd3bd23239 (patch) | |
tree | 4e8d6dae6a907524da0f1603ad6668f3183fd516 /src | |
parent | Make tests runnable (diff) | |
download | testbench-ui-1525dd9f819b310a48657d3bbfd748bd3bd23239.tar.gz testbench-ui-1525dd9f819b310a48657d3bbfd748bd3bd23239.zip |
Test lua function mapping
Diffstat (limited to 'src')
-rw-r--r-- | src/testbench.rs | 22 |
1 files changed, 16 insertions, 6 deletions
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<String>| Ok(()))?; + let ui_print = context.create_function(|_, strings: Variadic<String>| { + 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<P>(&mut self, path: P) -> io::Result<()> - where - P: AsRef<Path>, + pub fn load_tests(&mut self) -> io::Result<()> { - let entries: Result<Vec<PathBuf>, io::Error> = fs::read_dir(path)? + let entries: Result<Vec<PathBuf>, io::Error> = fs::read_dir(&self.tests_path)? .into_iter() .map(|r| r.map(|f| f.path())) .collect(); |