1
- // use bevy::app::App;
2
- // use bevy_mod_scripting_functions::ScriptFunctionsPlugin;
3
- // use bevy_mod_scripting_rhai::RhaiScriptingPlugin;
1
+ use bevy_mod_scripting_rhai:: RhaiScriptingPlugin ;
4
2
use libtest_mimic:: { Arguments , Failed , Trial } ;
3
+ use script_integration_test_harness:: execute_integration_test;
5
4
use std:: {
6
5
fs:: { self , DirEntry } ,
7
6
io, panic,
8
7
path:: { Path , PathBuf } ,
9
8
} ;
10
- // use test_utils::test_data::setup_integration_test;
11
-
12
- // Initializes world for tests
13
- // fn init_app() -> App {
14
- // let mut app = setup_integration_test(|_, _| {});
15
-
16
- // app.add_plugins(RhaiScriptingPlugin::default())
17
- // .add_plugins(ScriptFunctionsPlugin);
18
-
19
- // app.finish();
20
- // app.cleanup();
21
-
22
- // app
23
- // }
24
9
25
10
struct Test {
26
11
code : String ,
@@ -29,51 +14,57 @@ struct Test {
29
14
30
15
impl Test {
31
16
fn execute ( self ) -> Result < ( ) , Failed > {
32
- println ! ( "Running test: {}" , self . name( ) ) ;
33
- println ! ( "Code: {}" , self . code) ;
34
- // let lua = Lua::new();
35
- // set file information
36
- // let mut app = init_app();
37
- // app.add_systems(schedule, systems);
38
-
39
- // let mut lua = lua_context_load(
40
- // &(self.name()).into(),
41
- // self.code.as_bytes(),
42
- // &context_settings.context_initializers,
43
- // &context_settings.context_pre_handling_initializers,
44
- // app.world_mut(),
45
- // &mut (),
46
- // )
47
- // .map_err(|e| {
48
- // let world = app.world_mut();
49
- // let world = WorldAccessGuard::new(world);
50
- // let msg = e.display_with_world(Arc::new(world));
51
- // Failed::from(msg)
52
- // })?;
53
-
54
- // lua_handler(
55
- // vec![ScriptValue::Unit],
56
- // Entity::from_raw(1),
57
- // &(self.name()).into(),
58
- // &CallbackLabel::new("on_test").ok_or("invalid callback label")?,
59
- // &mut lua,
60
- // &context_settings.context_pre_handling_initializers,
61
- // &mut (),
62
- // app.world_mut(),
63
- // )
64
- // .map_err(|e| {
65
- // let world = app.world_mut();
66
- // let world = WorldAccessGuard::new(world);
67
- // let msg = e.display_with_world(Arc::new(world));
68
- // Failed::from(msg)
69
- // })?;
70
-
71
- Ok ( ( ) )
17
+ execute_integration_test :: < RhaiScriptingPlugin , _ , _ > (
18
+ |world, type_registry| {
19
+ let _ = world;
20
+ let _ = type_registry;
21
+ } ,
22
+ |app| {
23
+ app. add_plugins ( RhaiScriptingPlugin :: default ( ) ) ;
24
+ // app.add_context_initializer::<LuaScriptingPlugin>(|_,ctxt: &mut Lua| {
25
+ // let globals = ctxt.globals();
26
+ // globals.set(
27
+ // "assert_throws",
28
+ // ctxt.create_function(|lua, (f, reg): (Function, String)| {
29
+ // let world = lua.get_world();
30
+ // let result = f.call::<()>(MultiValue::new());
31
+ // let err = match result {
32
+ // Ok(_) => {
33
+ // return Err(mlua::Error::external(
34
+ // "Expected function to throw error, but it did not.",
35
+ // ))
36
+ // }
37
+ // Err(e) =>
38
+ // ScriptError::from_mlua_error(e).display_with_world(world)
39
+ // ,
40
+ // };
41
+
42
+ // let regex = regex::Regex::new(®).unwrap();
43
+ // if regex.is_match(&err) {
44
+ // Ok(())
45
+ // } else {
46
+ // Err(mlua::Error::external(
47
+ // format!(
48
+ // "Expected error message to match the regex: \n{}\n\nBut got:\n{}",
49
+ // regex.as_str(),
50
+ // err
51
+ // ),
52
+ // ))
53
+ // }
54
+ // })?,
55
+ // )?;
56
+ // Ok(())
57
+ // });
58
+ } ,
59
+ self . path . as_os_str ( ) . to_str ( ) . unwrap ( ) ,
60
+ self . code . as_bytes ( ) ,
61
+ )
62
+ . map_err ( Failed :: from)
72
63
}
73
64
74
65
fn name ( & self ) -> String {
75
66
format ! (
76
- "lua_test - {}" ,
67
+ "script_test - lua - {}" ,
77
68
self . path
78
69
. to_string_lossy( )
79
70
. split( & format!( "tests{}data" , std:: path:: MAIN_SEPARATOR ) )
0 commit comments