From 7619d583c453a2846a16117604da97b90bee6e0f Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Sat, 15 Jan 2022 12:06:37 -0500 Subject: [PATCH] wip test case for lsp --- cli/tests/integration/lsp_tests.rs | 62 ++++++++++++++++++++++++++++++ test_util/src/lsp.rs | 2 +- 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index 21894f7e82..2c20cafe38 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -1542,6 +1542,68 @@ fn lsp_format_exclude_with_config() { shutdown(&mut client); } +#[test] +fn lsp_format_exclude_default_config() { + let temp_dir = TempDir::new().unwrap(); + let workspace_root = temp_dir.path(); + + fs::write( + workspace_root.join("deno.json"), + br#" + { + "fmt": { + "files": { + "exclude": [ "ignored.ts" ] + } + } + } + "#, + ) + .unwrap(); + + let mut params: lsp::InitializeParams = + serde_json::from_value(load_fixture("initialize_params.json")).unwrap(); + params.root_uri = Some(Url::from_file_path(workspace_root).unwrap()); + + let mut client = LspClient::new(&deno_exe_path()).unwrap(); + client + .write_request::<_, _, Value>("initialize", params) + .unwrap(); + + let file_uri = + ModuleSpecifier::from_file_path(workspace_root.join("ignored.ts")).unwrap(); + + fs::write(workspace_root.join("ignored.ts"), "foo").unwrap(); + did_open( + &mut client, + json!({ + "textDocument": { + "uri": file_uri, + "languageId": "typescript", + "version": 1, + "text": "function myFunc(){}" + } + }), + ); + let (maybe_res, maybe_err) = client + .write_request( + "textDocument/formatting", + json!({ + "textDocument": { + "uri": file_uri + }, + "options": { + "tabSize": 2, + "insertSpaces": true + } + }), + ) + .unwrap(); + assert!(maybe_err.is_none()); + assert_eq!(maybe_res, Some(json!(null))); + shutdown(&mut client); +} + #[test] fn lsp_large_doc_changes() { let mut client = init("initialize_params.json"); diff --git a/test_util/src/lsp.rs b/test_util/src/lsp.rs index 92dc98102c..5fa2627dc8 100644 --- a/test_util/src/lsp.rs +++ b/test_util/src/lsp.rs @@ -165,7 +165,7 @@ impl LspClient { .arg("lsp") .stdin(Stdio::piped()) .stdout(Stdio::piped()) - .stderr(Stdio::null()) + //.stderr(Stdio::null()) .spawn()?; let stdout = child.stdout.take().unwrap();