Skip to content

Commit

Permalink
BE: Swap two tests around
Browse files Browse the repository at this point in the history
Summary: This keeps the logical order intact when adding more tests for the buck build info

Reviewed By: jcpetruzza

Differential Revision: D59855924

fbshipit-source-id: a8e80174a109ed37494986434aeb27a23cb3fc5c
  • Loading branch information
alanz authored and facebook-github-bot committed Jul 17, 2024
1 parent 2cda1c3 commit f807c30
Showing 1 changed file with 57 additions and 57 deletions.
114 changes: 57 additions & 57 deletions crates/elp/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit f807c30

Please sign in to comment.