Fix diagnostics randomized tests (#21775)

These were silently passing after the delay in updating diagnostics was
added.

Co-Authored-By: Max <max@zed.dev>

cc @someonetoignore

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
This commit is contained in:
Conrad Irwin 2024-12-09 21:56:43 -07:00 committed by GitHub
parent 8a85d6ef96
commit a35ef5b79f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 66 additions and 61 deletions

View file

@ -6,8 +6,9 @@ use gpui::{AppContext, SemanticVersion, UpdateGlobal};
use http_client::Url;
use language::{
language_settings::{language_settings, AllLanguageSettings, LanguageSettingsContent},
tree_sitter_rust, tree_sitter_typescript, Diagnostic, DiagnosticSet, DiskState, FakeLspAdapter,
LanguageConfig, LanguageMatcher, LanguageName, LineEnding, OffsetRangeExt, Point, ToPoint,
tree_sitter_rust, tree_sitter_typescript, Diagnostic, DiagnosticEntry, DiagnosticSet,
DiskState, FakeLspAdapter, LanguageConfig, LanguageMatcher, LanguageName, LineEnding,
OffsetRangeExt, Point, ToPoint,
};
use lsp::{
notification::DidRenameFiles, DiagnosticSeverity, DocumentChanges, FileOperationFilter,
@ -987,6 +988,7 @@ async fn test_single_file_worktrees_diagnostics(cx: &mut gpui::TestAppContext) {
.await;
let project = Project::test(fs, ["/dir/a.rs".as_ref(), "/dir/b.rs".as_ref()], cx).await;
let lsp_store = project.read_with(cx, |project, _| project.lsp_store());
let buffer_a = project
.update(cx, |project, cx| project.open_local_buffer("/dir/a.rs", cx))
@ -997,8 +999,8 @@ async fn test_single_file_worktrees_diagnostics(cx: &mut gpui::TestAppContext) {
.await
.unwrap();
project.update(cx, |project, cx| {
project
lsp_store.update(cx, |lsp_store, cx| {
lsp_store
.update_diagnostics(
LanguageServerId(0),
lsp::PublishDiagnosticsParams {
@ -1015,7 +1017,7 @@ async fn test_single_file_worktrees_diagnostics(cx: &mut gpui::TestAppContext) {
cx,
)
.unwrap();
project
lsp_store
.update_diagnostics(
LanguageServerId(0),
lsp::PublishDiagnosticsParams {
@ -1086,6 +1088,7 @@ async fn test_omitted_diagnostics(cx: &mut gpui::TestAppContext) {
.await;
let project = Project::test(fs, ["/root/dir".as_ref()], cx).await;
let lsp_store = project.read_with(cx, |project, _| project.lsp_store());
let (worktree, _) = project
.update(cx, |project, cx| {
project.find_or_create_worktree("/root/dir", true, cx)
@ -1103,8 +1106,8 @@ async fn test_omitted_diagnostics(cx: &mut gpui::TestAppContext) {
let other_worktree_id = worktree.update(cx, |tree, _| tree.id());
let server_id = LanguageServerId(0);
project.update(cx, |project, cx| {
project
lsp_store.update(cx, |lsp_store, cx| {
lsp_store
.update_diagnostics(
server_id,
lsp::PublishDiagnosticsParams {
@ -1121,7 +1124,7 @@ async fn test_omitted_diagnostics(cx: &mut gpui::TestAppContext) {
cx,
)
.unwrap();
project
lsp_store
.update_diagnostics(
server_id,
lsp::PublishDiagnosticsParams {
@ -2018,9 +2021,9 @@ async fn test_empty_diagnostic_ranges(cx: &mut gpui::TestAppContext) {
project.update(cx, |project, cx| {
project.lsp_store.update(cx, |lsp_store, cx| {
lsp_store
.update_buffer_diagnostics(
&buffer,
.update_diagnostic_entries(
LanguageServerId(0),
PathBuf::from("/dir/a.rs"),
None,
vec![
DiagnosticEntry {
@ -2078,9 +2081,10 @@ async fn test_diagnostics_from_multiple_language_servers(cx: &mut gpui::TestAppC
.await;
let project = Project::test(fs, ["/dir".as_ref()], cx).await;
let lsp_store = project.read_with(cx, |project, _| project.lsp_store.clone());
project.update(cx, |project, cx| {
project
lsp_store.update(cx, |lsp_store, cx| {
lsp_store
.update_diagnostic_entries(
LanguageServerId(0),
Path::new("/dir/a.rs").to_owned(),
@ -2097,7 +2101,7 @@ async fn test_diagnostics_from_multiple_language_servers(cx: &mut gpui::TestAppC
cx,
)
.unwrap();
project
lsp_store
.update_diagnostic_entries(
LanguageServerId(1),
Path::new("/dir/a.rs").to_owned(),
@ -2116,7 +2120,7 @@ async fn test_diagnostics_from_multiple_language_servers(cx: &mut gpui::TestAppC
.unwrap();
assert_eq!(
project.diagnostic_summary(false, cx),
lsp_store.diagnostic_summary(false, cx),
DiagnosticSummary {
error_count: 2,
warning_count: 0,
@ -3698,6 +3702,7 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
.await;
let project = Project::test(fs.clone(), ["/the-dir".as_ref()], cx).await;
let lsp_store = project.read_with(cx, |project, _| project.lsp_store());
let buffer = project
.update(cx, |p, cx| p.open_local_buffer("/the-dir/a.rs", cx))
.await
@ -3791,9 +3796,9 @@ async fn test_grouped_diagnostics(cx: &mut gpui::TestAppContext) {
version: None,
};
project
.update(cx, |p, cx| {
p.update_diagnostics(LanguageServerId(0), message, &[], cx)
lsp_store
.update(cx, |lsp_store, cx| {
lsp_store.update_diagnostics(LanguageServerId(0), message, &[], cx)
})
.unwrap();
let buffer = buffer.update(cx, |buffer, _| buffer.snapshot());