Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions crates/elp/tests/slow-tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ use crate::support::diagnostic_project;

#[test]
fn test_run_mock_lsp() {
// Skip this test in GitHub CI - it fails there. See T251247921
if std::env::var("GITHUB_ACTIONS").is_ok() {
return;
}
if cfg!(feature = "buck") {
let workspace_root = AbsPathBuf::assert(
Utf8Path::new(env!("CARGO_WORKSPACE_DIR")).join("test/test_projects/end_to_end"),
Expand Down
51 changes: 47 additions & 4 deletions crates/project_model/src/rebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,7 @@ impl RebarProject {
.map(into_string)
.collect::<Result<_>>()?,
include_dirs,
macros: into_vec(map_pop(&mut term, "macros")?)?
.into_iter()
.map(|term: eetf::Term| into_tuple(term))
.collect::<Result<_>>()?,
macros: into_macros(map_pop(&mut term, "macros")?)?,
parse_transforms: into_vec(map_pop(&mut term, "parse_transforms")?)?,
app_type: is_dep,
include_path: vec![],
Expand Down Expand Up @@ -314,6 +311,52 @@ fn into_string(term: eetf::Term) -> Result<String> {
Ok(String::from_utf8(into_bin(term)?)?)
}

/// Convert a macro value from rebar3 manifest format to proper eetf::Term.
/// rebar3 stores macro values as binaries (e.g., <<"true">> for -D TEST=true).
/// We need to parse these and convert to the appropriate term type.
fn convert_macro_value(term: eetf::Term) -> eetf::Term {
match term {
eetf::Term::Binary(eetf::Binary { bytes }) => {
// Try to parse the binary as a string
if let Ok(s) = String::from_utf8(bytes.clone()) {
// Try to parse as integer first
if let Ok(n) = s.parse::<i32>() {
return eetf::FixInteger::from(n).into();
}
// Otherwise treat as an atom (handles true, false, and other atoms)
return eetf::Atom::from(s).into();
}
// If not valid UTF-8, keep as binary
eetf::Term::Binary(eetf::Binary { bytes })
}
// Non-binary values pass through unchanged
other => other,
}
}

/// Parse macros from rebar3 manifest.
/// Supports both old format (list of maps with key/value) and new format (direct map).
/// Old format (rebar3 < 3.26.0): [#{key => 'TEST', value => <<"true">>}]
/// New format (rebar3 >= 3.26.0): #{'TEST' => <<"true">>}
fn into_macros(term: eetf::Term) -> Result<Vec<eetf::Term>> {
match term {
// New format: direct map #{'TEST' => <<"true">>}
eetf::Term::Map(eetf::Map { map }) => map
.into_iter()
.map(|(key, value)| {
let converted_value = convert_macro_value(value);
Ok(eetf::Term::Tuple(eetf::Tuple::from(vec![
key,
converted_value,
])))
})
.collect(),
// Old format: list of maps [#{key => ..., value => ...}]
eetf::Term::List(eetf::List { elements }) => elements.into_iter().map(into_tuple).collect(),
_ => bail!("expected a map or list for macros, got: {:?}", term),
}
}

fn into_tuple(mut term: eetf::Term) -> Result<eetf::Term> {
let key = map_pop(&mut term, "key")?;
let value = map_pop(&mut term, "value")?;
Expand Down
Loading