0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 17:34:47 -05:00

tests(lsp): fix flakey lsp integration test (#10875)

This commit is contained in:
Kitson Kelly 2021-06-07 19:12:07 +10:00 committed by GitHub
parent 3a4a47799f
commit d6f6e157bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2156,7 +2156,6 @@ fn lsp_diagnostics_deno_types() {
shutdown(&mut client); shutdown(&mut client);
} }
#[cfg(not(windows))]
#[test] #[test]
fn lsp_diagnostics_refresh_dependents() { fn lsp_diagnostics_refresh_dependents() {
let mut client = init("initialize_params.json"); let mut client = init("initialize_params.json");
@ -2264,35 +2263,28 @@ fn lsp_diagnostics_refresh_dependents() {
assert_eq!(method, "textDocument/publishDiagnostics"); assert_eq!(method, "textDocument/publishDiagnostics");
let (method, _) = client.read_notification::<Value>().unwrap(); let (method, _) = client.read_notification::<Value>().unwrap();
assert_eq!(method, "textDocument/publishDiagnostics"); assert_eq!(method, "textDocument/publishDiagnostics");
let (method, _) = client.read_notification::<Value>().unwrap(); // ensure that the server publishes any inflight diagnostics
assert_eq!(method, "textDocument/publishDiagnostics"); std::thread::sleep(std::time::Duration::from_millis(250));
let (method, _) = client.read_notification::<Value>().unwrap(); client
assert_eq!(method, "textDocument/publishDiagnostics"); .write_request::<_, _, Value>("shutdown", json!(null))
let (method, _) = client.read_notification::<Value>().unwrap();
assert_eq!(method, "textDocument/publishDiagnostics");
let (method, maybe_params) = client
.read_notification::<lsp::PublishDiagnosticsParams>()
.unwrap(); .unwrap();
assert_eq!(method, "textDocument/publishDiagnostics"); client.write_notification("exit", json!(null)).unwrap();
assert!(maybe_params.is_some());
let params = maybe_params.unwrap();
assert!(params.diagnostics.is_empty());
let (method, maybe_params) = client
.read_notification::<lsp::PublishDiagnosticsParams>()
.unwrap();
assert_eq!(method, "textDocument/publishDiagnostics");
assert!(maybe_params.is_some());
let params = maybe_params.unwrap();
assert!(params.diagnostics.is_empty());
let (method, maybe_params) = client
.read_notification::<lsp::PublishDiagnosticsParams>()
.unwrap();
assert_eq!(method, "textDocument/publishDiagnostics");
assert!(maybe_params.is_some());
let params = maybe_params.unwrap();
assert!(params.diagnostics.is_empty());
shutdown(&mut client); let queue_len = client.queue_len();
assert!(!client.queue_is_empty());
for i in 0..queue_len {
let (method, maybe_params) = client
.read_notification::<lsp::PublishDiagnosticsParams>()
.unwrap();
assert_eq!(method, "textDocument/publishDiagnostics");
// the last 3 diagnostic publishes should be the clear of any diagnostics
if queue_len - i <= 3 {
assert!(maybe_params.is_some());
let params = maybe_params.unwrap();
assert!(params.diagnostics.is_empty());
}
}
assert!(client.queue_is_empty());
} }
#[derive(Deserialize)] #[derive(Deserialize)]