summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorLuca Casonato <lucacasonato@yahoo.com>2020-12-21 14:44:26 +0100
committerGitHub <noreply@github.com>2020-12-21 08:44:26 -0500
commitbd85d0ed420b792eebdd81f88fca503e028c9565 (patch)
treed6f8d5baf4c3c0d760bea2b6b221189674d2e54b /cli/tests
parent3078fcf55a8aa04d26316ab353d84f2c9512bd47 (diff)
refactor: rewrite lsp to be async (#8727)
Co-authored-by: Luca Casonato <lucacasonato@yahoo.com>
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/lsp_tests.rs88
1 files changed, 0 insertions, 88 deletions
diff --git a/cli/tests/lsp_tests.rs b/cli/tests/lsp_tests.rs
deleted file mode 100644
index 7de655ac8..000000000
--- a/cli/tests/lsp_tests.rs
+++ /dev/null
@@ -1,88 +0,0 @@
-// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-
-///!
-///! Integration test for the Deno Language Server (`deno lsp`)
-///!
-use std::fs;
-use std::io::Read;
-use std::io::Write;
-use std::process::Stdio;
-
-struct LspIntegrationTest {
- pub fixtures: Vec<&'static str>,
-}
-
-impl LspIntegrationTest {
- pub fn run(&self) -> (String, String) {
- let root_path = test_util::root_path();
- let deno_exe = test_util::deno_exe_path();
- let tests_dir = root_path.join("cli/tests/lsp");
- println!("tests_dir: {:?} deno_exe: {:?}", tests_dir, deno_exe);
- let mut command = test_util::deno_cmd();
- command
- .arg("lsp")
- .stdin(Stdio::piped())
- .stdout(Stdio::piped())
- .stderr(Stdio::piped());
-
- let process = command.spawn().expect("failed to execute deno");
-
- for fixture in &self.fixtures {
- let mut stdin = process.stdin.as_ref().unwrap();
- let fixture_path = tests_dir.join(fixture);
- let content =
- fs::read_to_string(&fixture_path).expect("could not read fixture");
- let content_length = content.chars().count();
- write!(
- stdin,
- "Content-Length: {}\r\n\r\n{}",
- content_length, content
- )
- .unwrap();
- }
-
- let mut so = String::new();
- process.stdout.unwrap().read_to_string(&mut so).unwrap();
-
- let mut se = String::new();
- process.stderr.unwrap().read_to_string(&mut se).unwrap();
-
- (so, se)
- }
-}
-
-#[test]
-fn test_lsp_startup_shutdown() {
- let test = LspIntegrationTest {
- fixtures: vec![
- "initialize_request.json",
- "initialized_notification.json",
- "shutdown_request.json",
- "exit_notification.json",
- ],
- };
- let (response, out) = test.run();
- assert!(response.contains("deno-language-server"));
- assert!(out.contains("Connected to \"test-harness\" 1.0.0"));
-}
-
-#[test]
-fn test_lsp_hover() {
- // a straight forward integration tests starts up the lsp, opens a document
- // which logs `Deno.args` to the console, and hovers over the `args` property
- // to get the intellisense about it, which is a total end-to-end test that
- // includes sending information in and out of the TypeScript compiler.
- let test = LspIntegrationTest {
- fixtures: vec![
- "initialize_request.json",
- "initialized_notification.json",
- "did_open_notification.json",
- "hover_request.json",
- "shutdown_request.json",
- "exit_notification.json",
- ],
- };
- let (response, out) = test.run();
- assert!(response.contains("const Deno.args: string[]"));
- assert!(out.contains("Connected to \"test-harness\" 1.0.0"));
-}