on master help sign in
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.

commit313579d27ce6ad55b5c2410856e6aa62a7778320 authorMichael Davis <mcarsondavis@gmail.com> dateThu 20 Oct 2022, 14:14 (4 years ago) parent1243db1
1 file changed+29−1
helix-term/tests/test/helpers.rs+29−1
helix-term/tests/test/helpers.rs+29−1
@@ -143,9 +143,27 @@ pub async fn test_key_sequence_with_input_text<T: Into<TestCase>>(
143143
144144/// Generates language configs that merge in overrides, like a user language
145145/// config. The argument string must be a raw TOML document.
146+///
147+/// By default, language server configuration is dropped from the languages.toml
148+/// document. If a language-server is necessary for a test, it must be explicitly
149+/// added in `overrides`.
146150pub fn test_syntax_conf(overrides: Option<String>) -> helix_core::syntax::Configuration {
147151 let mut lang = helix_loader::config::default_lang_config();
148152
153+ for lang_config in lang
154+ .as_table_mut()
155+ .expect("Expected languages.toml to be a table")
156+ .get_mut("language")
157+ .expect("Expected languages.toml to have \"language\" keys")
158+ .as_array_mut()
159+ .expect("Expected an array of language configurations")
160+ {
161+ lang_config
162+ .as_table_mut()
163+ .expect("Expected language config to be a TOML table")
164+ .remove("language-server");
165+ }
166+
149167 if let Some(overrides) = overrides {
150168 let override_toml = toml::from_str(&overrides).unwrap();
151169 lang = helix_loader::merge_toml_values(lang, override_toml, 3);
@@ -236,7 +254,6 @@ pub fn new_readonly_tempfile() -> anyhow::Result<NamedTempFile> {
236254 Ok(file)
237255}
238256
239−#[derive(Default)]
240257pub struct AppBuilder {
241258 args: Args,
242259 config: Config,
@@ -244,6 +261,17 @@ pub struct AppBuilder {
244261 input: Option<(String, Selection)>,
245262}
246263
264+impl Default for AppBuilder {
265+ fn default() -> Self {
266+ Self {
267+ args: Args::default(),
268+ config: Config::default(),
269+ syn_conf: test_syntax_conf(None),
270+ input: None,
271+ }
272+ }
273+}
274+
247275impl AppBuilder {
248276 pub fn new() -> Self {
249277 AppBuilder::default()