1use 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(file_path);
12 cmd
13}
14
15pub const COMMANDS: [CommandType; 3] = [
16 CommandType::Direct("fprettify"),
17 CommandType::Uv("fprettify"),
18 CommandType::Pipx("fprettify"),
19];
20
21pub const IS_STDIN: bool = false;
22
23#[cfg(test)]
24mod test_fprettify {
25 #[test_with::executable(fprettify || pipx || uv)]
26 fn test_fprettify_fortran_e500b54621ef1a7a() {
27 let input = r#"program demo
28integer :: endif,if,elseif
29integer,DIMENSION(2) :: function
30endif=3;if=2
31if(endif==2)then
32endif=5
33elseif=if+4*(endif+&
342**10)
35elseif(endif==3)then
36function(if)=endif/elseif
37print*,endif
38endif
39end program"#;
40
41 let output = r#"program demo
42 integer :: endif, if, elseif
43 integer, DIMENSION(2) :: function
44 endif = 3; if = 2
45 if (endif == 2) then
46 endif = 5
47 elseif = if + 4*(endif + &
48 2**10)
49 elseif (endif == 3) then
50 function(if) = endif/elseif
51 print *, endif
52 end if
53end program
54"#;
55
56 let file_ext = crate::fttype::get_file_extension("fortran");
57
58 let snippet =
59 crate::execution::setup_snippet(input, &file_ext).expect("it to create a snippet file");
60
61 let result = crate::tools::Tooling::Fprettify
62 .format_snippet(
63 snippet.path(),
64 crate::testing::DEFAULT_TEST_FORMATTER_TIMEOUT,
65 crate::testing::DEFAULT_TEST_DEBUG_ENABLED,
66 &crate::config::MdsfConfigRunners::all(),
67 )
68 .expect("it to be successful")
69 .1
70 .expect("it to be some");
71
72 assert_eq!(result, output);
73 }
74}