mdsf/tools/
google_java_format.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("google-java-format")];
17
18#[cfg(test)]
19mod test_google_java_format {
20 #[test_with::executable(google-java-format)]
21 fn test_google_java_format_java_9d3ffaedafc37e65() {
22 let input = r#"class HelloWorld {
23 public static void main(String[] args) {
24 System.out.println("Hello");
25 System.out.println("World!");
26 }
27}"#;
28
29 let output = r#"class HelloWorld {
30 public static void main(String[] args) {
31 System.out.println("Hello");
32 System.out.println("World!");
33 }
34}
35"#;
36
37 let file_ext = crate::fttype::get_file_extension("java");
38
39 let snippet =
40 crate::execution::setup_snippet(input, &file_ext).expect("it to create a snippet file");
41
42 let result =
43 crate::execution::run_tools(&super::COMMANDS, snippet.path(), super::set_args, 0)
44 .expect("it to be successful")
45 .1
46 .expect("it to be some");
47
48 assert_eq!(result, output);
49 }
50}