diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2021-06-07 19:12:07 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-07 19:12:07 +1000 |
commit | d6f6e157bddc02a64beaa1c96fcda8d8ea27aa6d (patch) | |
tree | ade2940b1b3bc89faa327faf312e79ca98968def /cli/tests/integration_tests_lsp.rs | |
parent | 3a4a47799fe395a4ceb253c394724f54192150d2 (diff) |
tests(lsp): fix flakey lsp integration test (#10875)
Diffstat (limited to 'cli/tests/integration_tests_lsp.rs')
-rw-r--r-- | cli/tests/integration_tests_lsp.rs | 48 |
1 files changed, 20 insertions, 28 deletions
diff --git a/cli/tests/integration_tests_lsp.rs b/cli/tests/integration_tests_lsp.rs index b6d9cde54..e36de9ae3 100644 --- a/cli/tests/integration_tests_lsp.rs +++ b/cli/tests/integration_tests_lsp.rs @@ -2156,7 +2156,6 @@ fn lsp_diagnostics_deno_types() { shutdown(&mut client); } -#[cfg(not(windows))] #[test] fn lsp_diagnostics_refresh_dependents() { let mut client = init("initialize_params.json"); @@ -2264,35 +2263,28 @@ fn lsp_diagnostics_refresh_dependents() { assert_eq!(method, "textDocument/publishDiagnostics"); let (method, _) = client.read_notification::<Value>().unwrap(); assert_eq!(method, "textDocument/publishDiagnostics"); - let (method, _) = client.read_notification::<Value>().unwrap(); - assert_eq!(method, "textDocument/publishDiagnostics"); - let (method, _) = client.read_notification::<Value>().unwrap(); - assert_eq!(method, "textDocument/publishDiagnostics"); - let (method, _) = client.read_notification::<Value>().unwrap(); - assert_eq!(method, "textDocument/publishDiagnostics"); - 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()); - let (method, maybe_params) = client - .read_notification::<lsp::PublishDiagnosticsParams>() + // ensure that the server publishes any inflight diagnostics + std::thread::sleep(std::time::Duration::from_millis(250)); + client + .write_request::<_, _, Value>("shutdown", json!(null)) .unwrap(); - assert_eq!(method, "textDocument/publishDiagnostics"); - assert!(maybe_params.is_some()); - let params = maybe_params.unwrap(); - assert!(params.diagnostics.is_empty()); + client.write_notification("exit", json!(null)).unwrap(); - 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)] |