mirror of
https://github.com/WhatsApp/erlang-language-platform.git
synced 2025-12-23 12:26:48 +00:00
Make labels to denote test applications configurable
Some checks failed
ELP CI / edb (push) Has been cancelled
Deploy Website to GitHub Pages / Deploy Website to GitHub Pages (push) Has been cancelled
ELP CI / ci (26, 26.2.5.13, linux, 26.2, ubuntu-22.04, ubuntu-22.04-x64, x86_64-unknown-linux-gnu, true, linux-x64) (push) Has been cancelled
ELP CI / ci (26, 26.2.5.13, linux, 26.2, ubuntu-22.04-arm, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, true, linux-arm64) (push) Has been cancelled
ELP CI / ci (26, 26.2.5.13, macos, 26.2, macos-13, macos-13-x64, x86_64-apple-darwin, true, darwin-x64) (push) Has been cancelled
ELP CI / ci (26, 26.2.5.13, macos, 26.2, macos-latest, macos-latest-arm, aarch64-apple-darwin, true, darwin-arm64) (push) Has been cancelled
ELP CI / ci (26, 26.2.5.13, windows, 26.2, windows-2022, windows-2022-x64, x86_64-pc-windows-msvc, true, win32-x64) (push) Has been cancelled
ELP CI / ci (27, 27.3.4, linux, 27.3, ubuntu-22.04, ubuntu-22.04-x64, x86_64-unknown-linux-gnu, false, linux-x64) (push) Has been cancelled
ELP CI / ci (27, 27.3.4, linux, 27.3, ubuntu-22.04-arm, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, false, linux-arm64) (push) Has been cancelled
ELP CI / ci (27, 27.3.4, macos, 27.3, macos-13, macos-13-x64, x86_64-apple-darwin, false, darwin-x64) (push) Has been cancelled
ELP CI / ci (27, 27.3.4, macos, 27.3, macos-latest, macos-latest-arm, aarch64-apple-darwin, false, darwin-arm64) (push) Has been cancelled
ELP CI / ci (27, 27.3.4, windows, 27.3, windows-2022, windows-2022-x64, x86_64-pc-windows-msvc, false, win32-x64) (push) Has been cancelled
ELP CI / ci (28, 28.0.1, linux, 28, ubuntu-22.04, ubuntu-22.04-x64, x86_64-unknown-linux-gnu, false, linux-x64) (push) Has been cancelled
ELP CI / ci (28, 28.0.1, linux, 28, ubuntu-22.04-arm, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, false, linux-arm64) (push) Has been cancelled
ELP CI / ci (28, 28.0.1, macos, 28, macos-13, macos-13-x64, x86_64-apple-darwin, false, darwin-x64) (push) Has been cancelled
ELP CI / ci (28, 28.0.1, macos, 28, macos-latest, macos-latest-arm, aarch64-apple-darwin, false, darwin-arm64) (push) Has been cancelled
ELP CI / ci (28, 28.0.1, windows, 28, windows-2022, windows-2022-x64, x86_64-pc-windows-msvc, false, win32-x64) (push) Has been cancelled
Some checks failed
ELP CI / edb (push) Has been cancelled
Deploy Website to GitHub Pages / Deploy Website to GitHub Pages (push) Has been cancelled
ELP CI / ci (26, 26.2.5.13, linux, 26.2, ubuntu-22.04, ubuntu-22.04-x64, x86_64-unknown-linux-gnu, true, linux-x64) (push) Has been cancelled
ELP CI / ci (26, 26.2.5.13, linux, 26.2, ubuntu-22.04-arm, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, true, linux-arm64) (push) Has been cancelled
ELP CI / ci (26, 26.2.5.13, macos, 26.2, macos-13, macos-13-x64, x86_64-apple-darwin, true, darwin-x64) (push) Has been cancelled
ELP CI / ci (26, 26.2.5.13, macos, 26.2, macos-latest, macos-latest-arm, aarch64-apple-darwin, true, darwin-arm64) (push) Has been cancelled
ELP CI / ci (26, 26.2.5.13, windows, 26.2, windows-2022, windows-2022-x64, x86_64-pc-windows-msvc, true, win32-x64) (push) Has been cancelled
ELP CI / ci (27, 27.3.4, linux, 27.3, ubuntu-22.04, ubuntu-22.04-x64, x86_64-unknown-linux-gnu, false, linux-x64) (push) Has been cancelled
ELP CI / ci (27, 27.3.4, linux, 27.3, ubuntu-22.04-arm, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, false, linux-arm64) (push) Has been cancelled
ELP CI / ci (27, 27.3.4, macos, 27.3, macos-13, macos-13-x64, x86_64-apple-darwin, false, darwin-x64) (push) Has been cancelled
ELP CI / ci (27, 27.3.4, macos, 27.3, macos-latest, macos-latest-arm, aarch64-apple-darwin, false, darwin-arm64) (push) Has been cancelled
ELP CI / ci (27, 27.3.4, windows, 27.3, windows-2022, windows-2022-x64, x86_64-pc-windows-msvc, false, win32-x64) (push) Has been cancelled
ELP CI / ci (28, 28.0.1, linux, 28, ubuntu-22.04, ubuntu-22.04-x64, x86_64-unknown-linux-gnu, false, linux-x64) (push) Has been cancelled
ELP CI / ci (28, 28.0.1, linux, 28, ubuntu-22.04-arm, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, false, linux-arm64) (push) Has been cancelled
ELP CI / ci (28, 28.0.1, macos, 28, macos-13, macos-13-x64, x86_64-apple-darwin, false, darwin-x64) (push) Has been cancelled
ELP CI / ci (28, 28.0.1, macos, 28, macos-latest, macos-latest-arm, aarch64-apple-darwin, false, darwin-arm64) (push) Has been cancelled
ELP CI / ci (28, 28.0.1, windows, 28, windows-2022, windows-2022-x64, x86_64-pc-windows-msvc, false, win32-x64) (push) Has been cancelled
Summary: Make it possible to customize the set of labels that in a Buck2 `erlang_application` target can identify a "test" application. Make it default to "test application". Reviewed By: alanz, michalmuskala Differential Revision: D88005051 fbshipit-source-id: d5a7cbb89373def5796420fa178c0a86fd72e3ed
This commit is contained in:
parent
87bc60c524
commit
3e873e691d
3 changed files with 43 additions and 9 deletions
|
|
@ -88,6 +88,14 @@ pub struct BuckConfig {
|
|||
#[serde(default)]
|
||||
pub excluded_targets: Vec<String>,
|
||||
pub(crate) source_root: Option<PathBuf>,
|
||||
/// Buck2 labels that denote test applications.
|
||||
/// Defaults to ["test_application"] if not specified.
|
||||
#[serde(default = "default_test_application_labels")]
|
||||
pub test_application_labels: Vec<String>,
|
||||
}
|
||||
|
||||
fn default_test_application_labels() -> Vec<String> {
|
||||
vec!["test_application".to_string()]
|
||||
}
|
||||
|
||||
impl BuckConfig {
|
||||
|
|
@ -726,7 +734,7 @@ fn load_buck_targets_bxl(
|
|||
root,
|
||||
name,
|
||||
buck_target,
|
||||
buck_config.build_deps,
|
||||
buck_config,
|
||||
targets_include_prelude,
|
||||
&mut dep_path,
|
||||
&mut target_info,
|
||||
|
|
@ -747,7 +755,7 @@ fn make_buck_target(
|
|||
root: &AbsPathBuf,
|
||||
name: &String,
|
||||
target: &BuckTarget,
|
||||
build_deps: bool,
|
||||
buck_config: &BuckConfig,
|
||||
targets_include_prelude: bool,
|
||||
dep_path: &mut FxHashMap<String, AbsPathBuf>,
|
||||
target_info: &mut TargetInfo,
|
||||
|
|
@ -763,7 +771,12 @@ fn make_buck_target(
|
|||
(src, TargetType::ErlangTest, false, None)
|
||||
} else {
|
||||
let mut private_header = false;
|
||||
let target_type = compute_target_type(name, target, targets_include_prelude);
|
||||
let target_type = compute_target_type(
|
||||
name,
|
||||
target,
|
||||
targets_include_prelude,
|
||||
&buck_config.test_application_labels,
|
||||
);
|
||||
let mut src_files = vec![];
|
||||
for src in &target.srcs {
|
||||
let src = json::canonicalize(buck_path_to_abs_path(root, src).unwrap())?;
|
||||
|
|
@ -774,7 +787,7 @@ fn make_buck_target(
|
|||
}
|
||||
|
||||
let ebin = match target_type {
|
||||
TargetType::ThirdParty if build_deps => dep_path
|
||||
TargetType::ThirdParty if buck_config.build_deps => dep_path
|
||||
.remove(name)
|
||||
.map(|dir| dir.join(Utf8PathBuf::from("ebin"))),
|
||||
TargetType::ThirdParty => Some(dir.clone()),
|
||||
|
|
@ -817,14 +830,17 @@ fn compute_target_type(
|
|||
name: &TargetFullName,
|
||||
target: &BuckTarget,
|
||||
targets_include_prelude: bool,
|
||||
test_application_labels: &[String],
|
||||
) -> TargetType {
|
||||
// Check if we are trying to work on the prelude itself
|
||||
let is_prelude_as_third_party = !targets_include_prelude && name.starts_with("prelude//");
|
||||
if is_prelude_as_third_party || name.contains("//third-party") {
|
||||
TargetType::ThirdParty
|
||||
} else {
|
||||
let test_application = target.labels.contains("test_application");
|
||||
if test_application {
|
||||
let is_test_application = test_application_labels
|
||||
.iter()
|
||||
.any(|label| target.labels.contains(label));
|
||||
if is_test_application {
|
||||
TargetType::ErlangTestUtils
|
||||
} else {
|
||||
TargetType::ErlangApp
|
||||
|
|
@ -1609,6 +1625,7 @@ mod tests {
|
|||
included_targets: vec![],
|
||||
excluded_targets: vec![],
|
||||
source_root: None,
|
||||
test_application_labels: vec!["test_application".to_string()],
|
||||
};
|
||||
let generated_args = if build_generated {
|
||||
vec!["--build_generated_code", "true"]
|
||||
|
|
|
|||
|
|
@ -1839,6 +1839,7 @@ mod tests {
|
|||
"root//target/four".to_string(),
|
||||
],
|
||||
source_root: Some(PathBuf::from("path/to/root")),
|
||||
test_application_labels: vec!["test_application".to_string()],
|
||||
}),
|
||||
eqwalizer: EqwalizerConfig {
|
||||
enable_all: true,
|
||||
|
|
@ -1864,6 +1865,7 @@ mod tests {
|
|||
included_targets = ["root//target/one", "root//target/two"]
|
||||
excluded_targets = ["root//target/three", "root//target/four"]
|
||||
source_root = "path/to/root"
|
||||
test_application_labels = ["test_application"]
|
||||
|
||||
[eqwalizer]
|
||||
enable_all = true
|
||||
|
|
@ -1937,6 +1939,9 @@ mod tests {
|
|||
source_root: Some(
|
||||
"path/to/root",
|
||||
),
|
||||
test_application_labels: [
|
||||
"test_application",
|
||||
],
|
||||
},
|
||||
),
|
||||
eqwalizer: EqwalizerConfig {
|
||||
|
|
|
|||
|
|
@ -111,9 +111,21 @@ Configure the interaction between ELP and the [Buck2](https://buck2.build/)
|
|||
build tool. See [this presentation](https://youtu.be/4ALgsBqNBhQ) for details
|
||||
about Erlang support for Buck2.
|
||||
|
||||
| Key | Type | Description |
|
||||
| ------- | ------- | -------------------------------- |
|
||||
| enabled | Boolean | Discover the project using Buck2 |
|
||||
| Key | Type | Description | Default |
|
||||
| ----------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------ | ---------------------- |
|
||||
| enabled | Boolean | Discover the project using Buck2 | |
|
||||
| test_application_labels | Array of Strings | Buck2 labels that identify test application targets. Targets with any of these labels will be treated as test utilities. | `["test_application"]` |
|
||||
|
||||
The `test_application_labels` setting allows you to customize which Buck2 labels
|
||||
indicate test applications. This is useful for:
|
||||
|
||||
Example usage:
|
||||
|
||||
```toml
|
||||
[buck]
|
||||
enabled = true
|
||||
test_application_labels = ["test_application", "integration_test", "e2e_test"]
|
||||
```
|
||||
|
||||
:::warning
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue