Skip to content

Commit

Permalink
Remove language-server configuration in integration tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
the-mikedavis authored and Shekhinah Memmel committed Dec 11, 2022
1 parent 5d68bc9 commit 1140bb7
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion helix-term/tests/test/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,27 @@ pub async fn test_key_sequence_with_input_text<T: Into<TestCase>>(

/// 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<String>) -> 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);
Expand Down Expand Up @@ -236,14 +254,24 @@ pub fn new_readonly_tempfile() -> anyhow::Result<NamedTempFile> {
Ok(file)
}

#[derive(Default)]
pub struct AppBuilder {
args: Args,
config: Config,
syn_conf: helix_core::syntax::Configuration,
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()
Expand Down

0 comments on commit 1140bb7

Please sign in to comment.