mdsf/tools/
luaformatter.rs1use crate::runners::CommandType;
5
6#[inline]
7pub fn set_args(
8 mut cmd: std::process::Command,
9 file_path: &std::path::Path,
10) -> std::process::Command {
11 cmd.arg("-i");
12 cmd.arg(file_path);
13 cmd
14}
15
16pub const COMMANDS: [CommandType; 1] = [CommandType::Direct("lua-format")];
17
18#[cfg(test)]
19mod test_luaformatter {
20 #[test_with::executable(lua-format)]
21 fn test_luaformatter_lua_df0e81b2c9a1a835() {
22 let input = r#"
23
24 local function add ( a , b
25)
26local c=a+b
27return c
28
29
30end
31 "#;
32
33 let output = r#"local function add(a, b)
34 local c = a + b
35 return c
36
37end
38"#;
39
40 let file_ext = crate::fttype::get_file_extension("lua");
41
42 let snippet =
43 crate::execution::setup_snippet(input, &file_ext).expect("it to create a snippet file");
44
45 let result =
46 crate::execution::run_tools(&super::COMMANDS, snippet.path(), super::set_args, 0)
47 .expect("it to be successful")
48 .1
49 .expect("it to be some");
50
51 assert_eq!(result, output);
52 }
53}