on master help sign in
disable lsp in integration tests
a5233cfSkyler Hawthorne
helix-term/tests/test/auto_indent.rs+1−1
@@ -7,7 +7,7 @@ async fn auto_indent_c() -> anyhow::Result<()> {
7 files: vec![(PathBuf::from("foo.c"), Position::default())],
7 files: vec![(PathBuf::from("foo.c"), Position::default())],
8 ..Default::default()
8 ..Default::default()
9 },
9 },
10− Config::default(),
10+ helpers::test_config(),
11 helpers::test_syntax_conf(None),
11 helpers::test_syntax_conf(None),
12 // switches to append mode?
12 // switches to append mode?
13 (
13 (
helix-term/tests/test/helpers.rs+20−23
@@ -8,8 +8,8 @@ use std::{
8use anyhow::bail;
8use anyhow::bail;
9use crossterm::event::{Event, KeyEvent};
9use crossterm::event::{Event, KeyEvent};
10use helix_core::{diagnostic::Severity, test, Selection, Transaction};
10use helix_core::{diagnostic::Severity, test, Selection, Transaction};
11−use helix_term::{application::Application, args::Args, config::Config};
11+use helix_term::{application::Application, args::Args, config::Config, keymap::merge_keys};
12−use helix_view::{doc, input::parse_macro, Editor};
12+use helix_view::{doc, editor::LspConfig, input::parse_macro, Editor};
13use tempfile::NamedTempFile;
13use tempfile::NamedTempFile;
14use tokio_stream::wrappers::UnboundedReceiverStream;
14use tokio_stream::wrappers::UnboundedReceiverStream;
15
15
@@ -118,7 +118,7 @@ pub async fn test_key_sequence_with_input_text<T: Into<TestCase>>(
118 let test_case = test_case.into();
118 let test_case = test_case.into();
119 let mut app = match app {
119 let mut app = match app {
120 Some(app) => app,
120 Some(app) => app,
121− None => Application::new(Args::default(), Config::default(), test_syntax_conf(None))?,
121+ None => Application::new(Args::default(), test_config(), test_syntax_conf(None))?,
122 };
122 };
123
123
124 let (view, doc) = helix_view::current!(app.editor);
124 let (view, doc) = helix_view::current!(app.editor);
@@ -143,27 +143,9 @@ pub async fn test_key_sequence_with_input_text<T: Into<TestCase>>(
143
143
144/// Generates language configs that merge in overrides, like a user language
144/// Generates language configs that merge in overrides, like a user language
145/// config. The argument string must be a raw TOML document.
145/// 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`.
150pub fn test_syntax_conf(overrides: Option<String>) -> helix_core::syntax::Configuration {
146pub fn test_syntax_conf(overrides: Option<String>) -> helix_core::syntax::Configuration {
151 let mut lang = helix_loader::config::default_lang_config();
147 let mut lang = helix_loader::config::default_lang_config();
152
148
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−
167 if let Some(overrides) = overrides {
149 if let Some(overrides) = overrides {
168 let override_toml = toml::from_str(&overrides).unwrap();
150 let override_toml = toml::from_str(&overrides).unwrap();
169 lang = helix_loader::merge_toml_values(lang, override_toml, 3);
151 lang = helix_loader::merge_toml_values(lang, override_toml, 3);
@@ -177,11 +159,12 @@ pub fn test_syntax_conf(overrides: Option<String>) -> helix_core::syntax::Config
177/// want to verify the resulting document and selection.
159/// want to verify the resulting document and selection.
178pub async fn test_with_config<T: Into<TestCase>>(
160pub async fn test_with_config<T: Into<TestCase>>(
179 args: Args,
161 args: Args,
180− config: Config,
162+ mut config: Config,
181 syn_conf: helix_core::syntax::Configuration,
163 syn_conf: helix_core::syntax::Configuration,
182 test_case: T,
164 test_case: T,
183) -> anyhow::Result<()> {
165) -> anyhow::Result<()> {
184 let test_case = test_case.into();
166 let test_case = test_case.into();
167+ config = helix_term::keymap::merge_keys(config);
185 let app = Application::new(args, config, syn_conf)?;
168 let app = Application::new(args, config, syn_conf)?;
186
169
187 test_key_sequence_with_input_text(
170 test_key_sequence_with_input_text(
@@ -205,7 +188,7 @@ pub async fn test_with_config<T: Into<TestCase>>(
205pub async fn test<T: Into<TestCase>>(test_case: T) -> anyhow::Result<()> {
188pub async fn test<T: Into<TestCase>>(test_case: T) -> anyhow::Result<()> {
206 test_with_config(
189 test_with_config(
207 Args::default(),
190 Args::default(),
208− Config::default(),
191+ test_config(),
209 test_syntax_conf(None),
192 test_syntax_conf(None),
210 test_case,
193 test_case,
211 )
194 )
@@ -226,6 +209,20 @@ pub fn temp_file_with_contents<S: AsRef<str>>(
226 Ok(temp_file)
209 Ok(temp_file)
227}
210}
228
211
212+/// Generates a config with defaults more suitable for integration tests
213+pub fn test_config() -> Config {
214+ merge_keys(Config {
215+ editor: helix_view::editor::Config {
216+ lsp: LspConfig {
217+ enable: false,
218+ ..Default::default()
219+ },
220+ ..Default::default()
221+ },
222+ ..Default::default()
223+ })
224+}
225+
229/// Replaces all LF chars with the system's appropriate line feed
226/// Replaces all LF chars with the system's appropriate line feed
230/// character, and if one doesn't exist already, appends the system's
227/// character, and if one doesn't exist already, appends the system's
231/// appropriate line ending to the end of a string.
228/// appropriate line ending to the end of a string.