Add installation test binaries for all remaining adapters

This commit is contained in:
Julia 2023-06-26 11:54:20 -04:00
parent 5632f24d24
commit 2a8d1343d6
12 changed files with 395 additions and 226 deletions

View file

@ -79,20 +79,19 @@ impl LspAdapter for RustLspAdapter {
container_dir: PathBuf,
_: &dyn LspAdapterDelegate,
) -> Option<LanguageServerBinary> {
(|| async move {
let mut last = None;
let mut entries = fs::read_dir(&container_dir).await?;
while let Some(entry) = entries.next().await {
last = Some(entry?.path());
}
get_cached_server_binary(container_dir).await
}
anyhow::Ok(LanguageServerBinary {
path: last.ok_or_else(|| anyhow!("no cached binary"))?,
arguments: Default::default(),
async fn installation_test_binary(
&self,
container_dir: PathBuf,
) -> Option<LanguageServerBinary> {
get_cached_server_binary(container_dir)
.await
.map(|mut binary| {
binary.arguments = vec!["--help".into()];
binary
})
})()
.await
.log_err()
}
async fn disk_based_diagnostic_sources(&self) -> Vec<String> {
@ -259,6 +258,22 @@ impl LspAdapter for RustLspAdapter {
})
}
}
async fn get_cached_server_binary(container_dir: PathBuf) -> Option<LanguageServerBinary> {
(|| async move {
let mut last = None;
let mut entries = fs::read_dir(&container_dir).await?;
while let Some(entry) = entries.next().await {
last = Some(entry?.path());
}
anyhow::Ok(LanguageServerBinary {
path: last.ok_or_else(|| anyhow!("no cached binary"))?,
arguments: Default::default(),
})
})()
.await
.log_err()
}
#[cfg(test)]
mod tests {