Skip to content
Draft
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
10 changes: 10 additions & 0 deletions crates/emmylua_code_analysis/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,13 @@ fn replace_placeholders(input: &str, workspace_folder: &str) -> String {
})
.to_string()
}

#[cfg(test)]
mod test {
use super::pre_process_path;

#[test]
fn pre_proc_path() {
panic!()
}
}
Comment on lines +207 to +215

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

This test module is incomplete as the test just panics, which will cause the test suite to fail. The PR title suggests this is for testing tilde expansion, so I've implemented a basic test for that. I've also renamed the test function to be more descriptive and added the necessary imports.

Additionally, I noticed a potential bug in pre_process_path when handling a path that is just ~. The current implementation uses &path[2..], which will panic if the path is just ~ (length 1). You might want to add another test case for this and fix the implementation. A robust implementation would handle ~, ~/, and ~/path correctly.

Suggested change
#[cfg(test)]
mod test {
use super::pre_process_path;
#[test]
fn pre_proc_path() {
panic!()
}
}
#[cfg(test)]
mod test {
use super::pre_process_path;
use std::path::Path;
#[test]
fn test_tilde_expansion() {
if let Some(home_dir) = dirs::home_dir() {
let workspace = Path::new("/tmp");
let input = "~/foo";
let expected = home_dir.join("foo").to_string_lossy().to_string();
assert_eq!(pre_process_path(input, workspace), expected);
}
}
}

Loading