diff --git a/crates/elp/src/bin/main.rs b/crates/elp/src/bin/main.rs index ab4c9ddd1..5cacff60e 100644 --- a/crates/elp/src/bin/main.rs +++ b/crates/elp/src/bin/main.rs @@ -793,6 +793,63 @@ mod tests { ); } + #[test] + fn build_info_json_not_buck() { + let tmp_dir = TempDir::new().expect("Could not create temporary directory"); + let tmp_path = tmp_dir.path(); + let tmp_file = tmp_path.join("test_build_info.json"); + fs::create_dir_all(tmp_path).expect("Could not create temporary directory path"); + let project = "diagnostics"; + let path_str = format!("{}/test_build_info.json", project_path(project)); + let args = args_vec![ + "build-info", + "--to", + tmp_file.clone(), + "--json", + "--project", + path_str + ]; + let (stdout, stderr, code) = elp(args); + assert_eq!( + code, 0, + "failed with unexpected exit code: got {} not {}\nstdout:\n{}\nstderr:\n{}", + code, 0, stdout, stderr + ); + assert_eq!( + stderr.is_empty(), + true, + "expected stderr to be empty, got:\n{}", + stderr + ); + assert!(PathBuf::from(tmp_file.clone()).exists()); + let content = fs::read_to_string(tmp_file).unwrap(); + expect![[r#" + { + "apps": [ + { + "name": "app_a", + "dir": "app_a", + "src_dirs": [ + "src" + ], + "extra_src_dirs": [ + "test" + ], + "include_dirs": [ + "include" + ], + "macros": { + "MEANING_OF_LIFE": "fortytwo", + "TEST": "true", + "COMMON_TEST": "true" + } + } + ], + "deps": [] + }"#]] + .assert_eq(content.as_str()); + } + #[test] fn build_info_json_buck() { if cfg!(feature = "buck") { @@ -851,63 +908,6 @@ mod tests { } } - #[test] - fn build_info_json_not_buck() { - let tmp_dir = TempDir::new().expect("Could not create temporary directory"); - let tmp_path = tmp_dir.path(); - let tmp_file = tmp_path.join("test_build_info.json"); - fs::create_dir_all(tmp_path).expect("Could not create temporary directory path"); - let project = "diagnostics"; - let path_str = format!("{}/test_build_info.json", project_path(project)); - let args = args_vec![ - "build-info", - "--to", - tmp_file.clone(), - "--json", - "--project", - path_str - ]; - let (stdout, stderr, code) = elp(args); - assert_eq!( - code, 0, - "failed with unexpected exit code: got {} not {}\nstdout:\n{}\nstderr:\n{}", - code, 0, stdout, stderr - ); - assert_eq!( - stderr.is_empty(), - true, - "expected stderr to be empty, got:\n{}", - stderr - ); - assert!(PathBuf::from(tmp_file.clone()).exists()); - let content = fs::read_to_string(tmp_file).unwrap(); - expect![[r#" - { - "apps": [ - { - "name": "app_a", - "dir": "app_a", - "src_dirs": [ - "src" - ], - "extra_src_dirs": [ - "test" - ], - "include_dirs": [ - "include" - ], - "macros": { - "MEANING_OF_LIFE": "fortytwo", - "TEST": "true", - "COMMON_TEST": "true" - } - } - ], - "deps": [] - }"#]] - .assert_eq(content.as_str()); - } - #[test_case(false ; "rebar")] #[test_case(true ; "buck")] fn lint_1(buck: bool) {