From 313579d27ce6ad55b5c2410856e6aa62a7778320 Mon Sep 17 00:00:00 2001 From: Michael Davis Date: Thu, 20 Oct 2022 14:14:27 -0500 Subject: [PATCH] Remove language-server configuration in integration tests This change removes language server configuration from the default languages.toml config for integration tests. No integration-tests currently depend on the availability of a language server but if any future test needs to, it may provide a language server configuration by passing an override into the `test_syntax_conf` helper. Language-servers in integration tests cause false-positive failures when running integration tests in GitHub Actions CI. The Windows runner appears to have `clangd` installed and all OS runners have the `R` binary installed but not the `R` language server package. If a test file created by `tempfile::NamedTempFile` happens to have a file extension of `r`, the test will most likely fail because the R language server will fail to start and will become a broken pipe, meaning that it will fail to shutdown within the timeout, causing a false-positive failure. This happens surprisingly often in practice. Language servers (especially rust-analyzer) also emit unnecessary log output when initializing, which this change silences. --- helix-term/tests/test/helpers.rs | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/helix-term/tests/test/helpers.rs b/helix-term/tests/test/helpers.rs index a2d53e9d8..e8bd6c35e 100644 --- a/helix-term/tests/test/helpers.rs +++ b/helix-term/tests/test/helpers.rs @@ -143,9 +143,27 @@ pub async fn test_key_sequence_with_input_text>( /// Generates language configs that merge in overrides, like a user language /// config. The argument string must be a raw TOML document. +/// +/// By default, language server configuration is dropped from the languages.toml +/// document. If a language-server is necessary for a test, it must be explicitly +/// added in `overrides`. pub fn test_syntax_conf(overrides: Option) -> helix_core::syntax::Configuration { let mut lang = helix_loader::config::default_lang_config(); + for lang_config in lang + .as_table_mut() + .expect("Expected languages.toml to be a table") + .get_mut("language") + .expect("Expected languages.toml to have \"language\" keys") + .as_array_mut() + .expect("Expected an array of language configurations") + { + lang_config + .as_table_mut() + .expect("Expected language config to be a TOML table") + .remove("language-server"); + } + if let Some(overrides) = overrides { let override_toml = toml::from_str(&overrides).unwrap(); lang = helix_loader::merge_toml_values(lang, override_toml, 3); @@ -236,7 +254,6 @@ pub fn new_readonly_tempfile() -> anyhow::Result { Ok(file) } -#[derive(Default)] pub struct AppBuilder { args: Args, config: Config, @@ -244,6 +261,17 @@ pub struct AppBuilder { input: Option<(String, Selection)>, } +impl Default for AppBuilder { + fn default() -> Self { + Self { + args: Args::default(), + config: Config::default(), + syn_conf: test_syntax_conf(None), + input: None, + } + } +} + impl AppBuilder { pub fn new() -> Self { AppBuilder::default()