Skip to content

Commit

Permalink
buck-bxl: make sure eqwalize-all does not process test files
Browse files Browse the repository at this point in the history
Summary:
The new buck-bxl project model in ELP was not properly tagging test files in the module index, so `elp eqwalize-all` was processing them too.

Not all of them are fully specced, so this results in reported failures.

This diff fixes that.

Reviewed By: TheGeorge

Differential Revision: D69244396

fbshipit-source-id: 1deac14a49a579fe7ce20b77d233ab5d4d48a7d7
  • Loading branch information
alanz authored and facebook-github-bot committed Feb 6, 2025
1 parent c938ca9 commit 1361dc6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 22 deletions.
2 changes: 1 addition & 1 deletion crates/base_db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ impl SourceRoot {
Some((file_id, FileSource::Extra, path))
} else if app_data.is_test_target == Some(true) {
// buck test target source file. It only has one.
Some((file_id, FileSource::Src, path))
Some((file_id, FileSource::Extra, path))
} else {
None
}
Expand Down
51 changes: 30 additions & 21 deletions crates/project_model/src/buck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -956,27 +956,36 @@ fn targets_to_project_data_bxl(
} else {
vec![]
};
let abs_src_dirs: FxHashSet<_> = target
.src_files
.iter()
.filter(|src| src.extension() == Some(&ERL_EXT))
.filter_map(|src| src.parent())
.map(|dir| dir.to_path_buf())
.filter(|dir| dir.file_name() != Some(&TEST_DIR))
.collect();
let extra_src_dirs: FxHashSet<String> = target
.src_files
.iter()
.filter(|src| src.extension() == Some(&ERL_EXT))
.filter_map(|src| src.parent())
.map(|dir| dir.to_path_buf())
.filter(|dir| dir.file_name() == Some(&TEST_DIR))
.filter_map(|d| {
d.strip_prefix(&target.dir.to_path_buf())
.map(|r| r.to_path_buf())
})
.map(|d| d.as_str().to_string())
.collect();
// Note: For BUCK targets, it is either a single test file in
// a test suite, or one or more files as an app target.
// This is indicated by TargetType::ErlangTest for the former
let (abs_src_dirs, extra_src_dirs) = match target.target_type {
TargetType::ErlangApp | TargetType::ThirdParty => (
target
.src_files
.iter()
.filter(|src| src.extension() == Some(&ERL_EXT))
.filter_map(|src| src.parent())
.map(|dir| dir.to_path_buf())
.collect(),
FxHashSet::default(),
),
TargetType::ErlangTest | TargetType::ErlangTestUtils => (
FxHashSet::default(),
target
.src_files
.iter()
.filter(|src| src.extension() == Some(&ERL_EXT))
.filter_map(|src| src.parent())
.map(|dir| dir.to_path_buf())
.filter_map(|d| {
d.strip_prefix(&target.dir.to_path_buf())
.map(|r| r.to_path_buf())
})
.map(|d| d.as_str().to_string())
.collect(),
),
};
let project_app_data = ProjectAppData {
name: AppName(target.app_name.clone()),
dir: target.dir.clone(),
Expand Down

0 comments on commit 1361dc6

Please sign in to comment.