aboutsummaryrefslogtreecommitdiff
path: root/helix-term/tests
diff options
context:
space:
mode:
authorMichael Davis2022-10-20 19:14:27 +0000
committerBlaž Hrastnik2022-10-20 23:43:15 +0000
commit313579d27ce6ad55b5c2410856e6aa62a7778320 (patch)
treea820574a08ff7ee556f028ff42ba2c0533d7b161 /helix-term/tests
parent1243db11a55a9f431a4b6bbf56c1953b2262d8b7 (diff)
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.
Diffstat (limited to 'helix-term/tests')
-rw-r--r--helix-term/tests/test/helpers.rs30
1 files changed, 29 insertions, 1 deletions
diff --git a/helix-term/tests/test/helpers.rs b/helix-term/tests/test/helpers.rs
index a2d53e9d..e8bd6c35 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<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);
@@ -236,7 +254,6 @@ pub fn new_readonly_tempfile() -> anyhow::Result<NamedTempFile> {
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()